ScatterCtrl: Included derivatives

git-svn-id: svn://ultimatepp.org/upp/trunk@14165 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2020-03-14 09:45:02 +00:00
parent a02a072a17
commit 65def7d923
5 changed files with 672 additions and 509 deletions

View file

@ -147,6 +147,13 @@ ProcessingTab::ProcessingTab()
tabFitRight.opSinus.WhenAction = THISBACK(OnOp);
tabFitRight.opSinusTend.WhenAction = THISBACK(OnOp);
tabFitRight.opSpline.WhenAction = THISBACK(OnOp);
tabFitRight.opDerivative.WhenAction = THISBACK(OnOp);
tabFitRight.derOrder.WhenAction = THISBACK(OnOp);
tabFitRight.derAccuracy.WhenAction = THISBACK(OnOp);
tabFitRight.opSG.WhenAction = THISBACK(OnOp);
tabFitRight.sgOrder.WhenAction = THISBACK(OnOp);
tabFitRight.sgSize.WhenAction = THISBACK(OnOp);
tabFitRight.sgDeg.WhenAction = THISBACK(OnOp);
tabFitRight.opMax.WhenAction = THISBACK(OnOp);
tabFitRight.opMin.WhenAction = THISBACK(OnOp);
tabFitRight.opMovAvg.WhenAction = THISBACK(OnOp);
@ -156,6 +163,20 @@ ProcessingTab::ProcessingTab()
tabFitRight.width.WhenLostFocus = THISBACK(OnUpdateSensitivity);
tabFitRight.width.WhenAction = THISBACK(OnUpdateSensitivity);
tabFitRight.opDerivative.Tip(t_("Numerical derivative including derivative order and accuracy (related to window size)"));
tabFitRight.derOrder <<= 1;
tabFitRight.derOrder.Tip(t_("Implemented orders are 1 (first) and 2 (second derivative)"));
tabFitRight.derAccuracy <<= 6;
tabFitRight.derAccuracy.SetInc(2);
tabFitRight.derAccuracy.Tip(t_("Implemented accuracies are 2, 4, 6 and 8"));
tabFitRight.opSG.Tip(t_("SavitzkyGolay filter including derivative order, window size and polynomial degree"));
tabFitRight.sgOrder <<= 0;
tabFitRight.sgOrder.Tip(t_("Implemented orders are 0 (just filter), 1 (first) and 2 (second derivative)"));
tabFitRight.sgSize <<= 5;
//tabFitRight.sgSize.SetInc(2);
tabFitRight.sgSize.Tip(t_("Window size"));
tabFitRight.sgDeg <<= 3;
tabFitRight.sgDeg.Tip(t_("Polynomial degree"));
tabFitRight.numDecimals <<= 3;
tabFitRight.numDecimals.WhenAction = THISBACK(UpdateEquations);
tabFitRight.showEquation.WhenAction = THISBACK(OnShowEquation);
@ -340,11 +361,13 @@ void ProcessingTab::OnOp()
tabFitLeft.scatter.ScatterDraw::Show(5, tabFitRight.opSinus);
tabFitLeft.scatter.ScatterDraw::Show(6, tabFitRight.opSinusTend);
tabFitLeft.scatter.ScatterDraw::Show(7, tabFitRight.opSpline);
tabFitLeft.scatter.ScatterDraw::Show(8, tabFitRight.opMax);
tabFitLeft.scatter.ScatterDraw::Show(9, tabFitRight.opMin);
tabFitLeft.scatter.ScatterDraw::Show(10,tabFitRight.opMovAvg);
tabFitLeft.scatter.ScatterDraw::Show(11,tabFitRight.opSecAvg);
tabFitLeft.scatter.ScatterDraw::Show(12,tabFitRight.opCumAvg);
tabFitLeft.scatter.ScatterDraw::Show(8, tabFitRight.opDerivative);
tabFitLeft.scatter.ScatterDraw::Show(9, tabFitRight.opSG);
tabFitLeft.scatter.ScatterDraw::Show(10,tabFitRight.opMax);
tabFitLeft.scatter.ScatterDraw::Show(11,tabFitRight.opMin);
tabFitLeft.scatter.ScatterDraw::Show(12,tabFitRight.opMovAvg);
tabFitLeft.scatter.ScatterDraw::Show(13,tabFitRight.opSecAvg);
tabFitLeft.scatter.ScatterDraw::Show(14,tabFitRight.opCumAvg);
UpdateEquations();
OnShowEquation();
@ -465,6 +488,8 @@ void ProcessingTab::UpdateField(const String _name, int _id)
tabFitLeft.scatter.AddSeries(sinus).NoMark().Stroke(1.5);
tabFitLeft.scatter.AddSeries(sinusTend).NoMark().Stroke(1.5);
tabFitLeft.scatter.AddSeries(spline).NoMark().Dash(LINE_SOLID).Stroke(1.5);
tabFitLeft.scatter.AddSeries(derivative).NoMark().Dash(LINE_SOLID).Stroke(1.5);
tabFitLeft.scatter.AddSeries(sg).NoMark().Dash(LINE_SOLID).Stroke(1.5);
tabFitLeft.scatter.AddSeries(upperEnvelope).Legend(pscatter->GetLegend(id) + String("-") + t_("Max"))
.NoMark().Dash(LINE_DASHED).Stroke(1.5).SetSequentialX(true);
tabFitLeft.scatter.AddSeries(lowerEnvelope).Legend(pscatter->GetLegend(id) + String("-") + t_("Min"))
@ -483,6 +508,11 @@ void ProcessingTab::UpdateField(const String _name, int _id)
tabFitRight.opSinus.Enable(false);
tabFitRight.opSinusTend.Enable(false);
tabFitRight.opSpline.Enable(false);
tabFitRight.opDerivative.Enable(false);
tabFitRight.derOrder.Enable(false);
tabFitRight.derAccuracy.Enable(false);
tabFitRight.opSG.Enable(false);
tabFitRight.sgOrder.Enable(false);
tabFitRight.opMax.Enable(false);
tabFitRight.opMin.Enable(false);
tabFitRight.opMovAvg.Enable(false);
@ -500,6 +530,24 @@ void ProcessingTab::OnUpdateSensitivity()
DataSource &data = tabFitLeft.scatter.GetDataSource(0);
bool refresh = false;
if (tabFitRight.opDerivative) {
bool isOdd = int(~(tabFitRight.derAccuracy))%2;
if (IsNull(tabFitRight.derAccuracy) || isOdd)
derivative.Clear();
else
derivative = data.DerivativeY(~tabFitRight.derOrder, ~tabFitRight.derAccuracy);
refresh = true;
}
if (tabFitRight.opSG) {
int side = int(~tabFitRight.sgSize)/2;
if (!SavitzkyGolay_CheckParams(side, side, ~tabFitRight.sgDeg, ~tabFitRight.sgOrder))
sg.Clear();
else
sg = data.SavitzkyGolayY(~tabFitRight.sgDeg, ~tabFitRight.sgSize, ~tabFitRight.sgOrder);
refresh = true;
}
if (tabFitRight.opMax && newWidthMax != tabFitRight.width) {
newWidthMax = tabFitRight.width;
@ -681,6 +729,8 @@ void ProcessingTab::OnShowEquation()
tabFitLeft.scatter.Legend(6, pscatter->GetLegend(id) + String("-") +
(show && tabFitRight.opSinusTend ? sinusTend.GetEquation(tabFitRight.numDecimals) : String(t_("Sinusoidal tend"))));
tabFitLeft.scatter.Legend(7, pscatter->GetLegend(id) + String("-") + String(t_("Spline")));
tabFitLeft.scatter.Legend(8, pscatter->GetLegend(id) + String("-") + String(Format(t_("Der_%d"), ~tabFitRight.derOrder)));
tabFitLeft.scatter.Legend(9, pscatter->GetLegend(id) + String("-") + String(Format(t_("S_G_%d"), ~tabFitRight.sgOrder)));
tabFitLeft.scatter.Refresh();
}

View file

@ -286,6 +286,8 @@ private:
PolynomialEquation3 cubic;
SinEquation sinus, sinusTend;
SplineEquation spline;
Vector<Pointf> derivative;
Vector<Pointf> sg;
Vector<Pointf> upperEnvelope, lowerEnvelope;
Vector<Pointf> movAvg, secAvg, cumAvg;
DataXRange dataXRange;

View file

@ -180,31 +180,32 @@ LAYOUT(ProcessingTabFitLeft, 356, 281)
ITEM(ScatterCtrl, scatter, SetPlotAreaLeftMargin(60).SetPlotAreaBottomMargin(50).ShowContextMenu(true).ShowPropertiesDlg(true).ShowProcessDlg(true).ShowButtons(true).HSizePosZ(0, 1).VSizePosZ(0, 0))
END_LAYOUT
LAYOUT(ProcessingTabFitRight, 232, 452)
ITEM(Option, opSeries, SetLabel(t_("Series")).LeftPosZ(4, 84).TopPosZ(3, 16))
ITEM(Option, opAverage, SetLabel(t_("Average")).LeftPosZ(4, 64).TopPosZ(23, 16))
ITEM(Option, opLinear, SetLabel(t_("Linear")).LeftPosZ(4, 64).TopPosZ(43, 16))
ITEM(Option, opCuadratic, SetLabel(t_("Cuadratic")).LeftPosZ(4, 64).TopPosZ(63, 16))
ITEM(Option, opCubic, SetLabel(t_("Cubic")).LeftPosZ(4, 64).TopPosZ(83, 16))
ITEM(Option, opSinus, SetLabel(t_("Sinusoidal")).LeftPosZ(4, 64).TopPosZ(103, 16))
ITEM(Option, opSinusTend, SetLabel(t_("Sin. tend.")).LeftPosZ(4, 64).TopPosZ(123, 16))
ITEM(Option, opSpline, SetLabel(t_("Spline")).LeftPosZ(4, 128).TopPosZ(143, 16))
ITEM(EditIntSpin, numDecimals, Max(20).Min(0).LeftPosZ(84, 36).TopPosZ(163, 19))
ITEM(Option, showEquation, SetLabel(t_("Show Eq.")).LeftPosZ(128, 72).TopPosZ(163, 16))
ITEM(Option, opMax, SetLabel(t_("Max curve")).LeftPosZ(4, 128).TopPosZ(187, 16))
ITEM(Option, opMin, SetLabel(t_("Min curve")).LeftPosZ(4, 128).TopPosZ(207, 16))
ITEM(Option, opMovAvg, SetLabel(t_("Moving Average")).LeftPosZ(4, 128).TopPosZ(227, 16))
ITEM(Option, opCumAvg, SetLabel(t_("Cumulative Average")).LeftPosZ(4, 128).TopPosZ(268, 16))
ITEM(Option, opSecAvg, SetLabel(t_("Sector Average")).LeftPosZ(4, 128).TopPosZ(247, 16))
ITEM(Button, butAutoSensSector, SetLabel(t_("Autosens")).LeftPosZ(136, 64).TopPosZ(247, 15))
ITEM(EditDoubleLostFocusSpin, width, LeftPosZ(136, 60).TopPosZ(211, 19))
ITEM(Label, dv___17, SetLabel(t_("Max imp.:")).HSizePosZ(4, 144).TopPosZ(332, 19))
ITEM(Label, dv___18, SetLabel(t_("R2 coeff.")).RightPosZ(0, 48).TopPosZ(4, 19))
ITEM(Label, dv___19, SetLabel(t_("Num decimals:")).LeftPosZ(4, 80).TopPosZ(163, 19))
ITEM(Label, dv___20, SetLabel(t_("Max:")).HSizePosZ(4, 144).TopPosZ(308, 19))
ITEM(Label, dv___21, SetLabel(t_("StdDev:")).LeftPosZ(4, 56).TopPosZ(428, 19))
ITEM(EditString, eMaxImp, SetEditable(false).HSizePosZ(64, 4).TopPosZ(332, 19))
ITEM(EditDouble, eStdDev, SetEditable(false).HSizePosZ(64, 4).TopPosZ(428, 19))
LAYOUT(ProcessingTabFitRight, 280, 484)
ITEM(Option, opSeries, SetLabel(t_("Series")).LeftPosZ(4, 84).TopPosZ(3, 19))
ITEM(Option, opAverage, SetLabel(t_("Average")).LeftPosZ(4, 64).TopPosZ(23, 19))
ITEM(Option, opLinear, SetLabel(t_("Linear")).LeftPosZ(4, 64).TopPosZ(43, 19))
ITEM(Option, opCuadratic, SetLabel(t_("Cuadratic")).LeftPosZ(4, 64).TopPosZ(63, 19))
ITEM(Option, opCubic, SetLabel(t_("Cubic")).LeftPosZ(4, 64).TopPosZ(83, 19))
ITEM(Option, opSinus, SetLabel(t_("Sinusoidal")).LeftPosZ(4, 64).TopPosZ(103, 19))
ITEM(Option, opSinusTend, SetLabel(t_("Sin. tend.")).LeftPosZ(4, 64).TopPosZ(123, 19))
ITEM(Option, opSG, SetLabel(t_("SG")).LeftPosZ(4, 36).TopPosZ(184, 19))
ITEM(Option, opSpline, SetLabel(t_("Spline")).LeftPosZ(4, 128).TopPosZ(143, 19))
ITEM(EditIntSpin, numDecimals, Max(20).Min(0).LeftPosZ(84, 36).TopPosZ(208, 19))
ITEM(Option, showEquation, SetLabel(t_("Show Eq.")).LeftPosZ(128, 72).TopPosZ(208, 19))
ITEM(Option, opMax, SetLabel(t_("Max curve")).LeftPosZ(4, 128).TopPosZ(232, 19))
ITEM(Option, opMin, SetLabel(t_("Min curve")).LeftPosZ(4, 128).TopPosZ(252, 19))
ITEM(Option, opMovAvg, SetLabel(t_("Moving Average")).LeftPosZ(4, 128).TopPosZ(272, 19))
ITEM(Option, opCumAvg, SetLabel(t_("Cumulative Average")).LeftPosZ(4, 128).TopPosZ(313, 19))
ITEM(Option, opSecAvg, SetLabel(t_("Sector Average")).LeftPosZ(4, 128).TopPosZ(292, 19))
ITEM(Button, butAutoSensSector, SetLabel(t_("Autosens")).LeftPosZ(136, 64).TopPosZ(292, 15))
ITEM(EditDoubleLostFocusSpin, width, LeftPosZ(136, 60).TopPosZ(256, 19))
ITEM(Label, dv___18, SetLabel(t_("Max imp.:")).HSizePosZ(4, 144).TopPosZ(377, 19))
ITEM(Label, dv___19, SetLabel(t_("R2 coeff.")).RightPosZ(0, 48).TopPosZ(4, 19))
ITEM(Label, dv___20, SetLabel(t_("Num decimals:")).LeftPosZ(4, 80).TopPosZ(208, 19))
ITEM(Label, dv___21, SetLabel(t_("Max:")).HSizePosZ(4, 144).TopPosZ(353, 19))
ITEM(Label, dv___22, SetLabel(t_("StdDev:")).LeftPosZ(4, 56).TopPosZ(473, 19))
ITEM(EditString, eMaxImp, SetEditable(false).HSizePosZ(64, 4).TopPosZ(377, 19))
ITEM(EditDouble, eStdDev, SetEditable(false).HSizePosZ(64, 4).TopPosZ(473, 19))
ITEM(EditString, eqSinusTend, SetEditable(false).HSizePosZ(68, 52).TopPosZ(123, 19))
ITEM(EditDouble, r2Linear, SetEditable(false).RightPosZ(4, 44).TopPosZ(43, 19))
ITEM(EditDouble, r2Cuadratic, SetEditable(false).RightPosZ(4, 44).TopPosZ(63, 19))
@ -213,18 +214,29 @@ LAYOUT(ProcessingTabFitRight, 232, 452)
ITEM(EditDouble, r2Sinus, SetEditable(false).RightPosZ(4, 44).TopPosZ(103, 19))
ITEM(EditString, eqCubic, SetEditable(false).HSizePosZ(68, 52).TopPosZ(83, 19))
ITEM(EditDouble, r2Cubic, SetEditable(false).RightPosZ(4, 44).TopPosZ(83, 19))
ITEM(EditString, eMax, SetEditable(false).HSizePosZ(64, 4).TopPosZ(308, 19))
ITEM(Label, dv___33, SetLabel(t_("Average:")).HSizePosZ(4, 144).TopPosZ(380, 19))
ITEM(EditDouble, eAverage, SetEditable(false).HSizePosZ(64, 4).TopPosZ(380, 19))
ITEM(EditString, eMax, SetEditable(false).HSizePosZ(64, 4).TopPosZ(353, 19))
ITEM(Label, dv___34, SetLabel(t_("Average:")).HSizePosZ(4, 144).TopPosZ(425, 19))
ITEM(EditDouble, eAverage, SetEditable(false).HSizePosZ(64, 4).TopPosZ(425, 19))
ITEM(EditString, eqLinear, SetEditable(false).HSizePosZ(68, 52).TopPosZ(43, 19))
ITEM(EditString, eqCuadratic, SetEditable(false).HSizePosZ(68, 52).TopPosZ(63, 19))
ITEM(EditString, eqAverage, SetEditable(false).HSizePosZ(68, 52).TopPosZ(23, 19))
ITEM(Label, dv___38, SetLabel(t_("Sensitivity")).LeftPosZ(136, 60).TopPosZ(195, 19))
ITEM(LabelBox, dv___39, SetLabel(t_("Statistical data")).HSizePosZ(0, 4).TopPosZ(284, 24))
ITEM(Label, dv___40, SetLabel(t_("RMS:")).LeftPosZ(4, 56).TopPosZ(404, 19))
ITEM(EditDouble, eRMS, SetEditable(false).HSizePosZ(64, 4).TopPosZ(404, 19))
ITEM(Label, dv___42, SetLabel(t_("Min:")).HSizePosZ(4, 144).TopPosZ(356, 19))
ITEM(EditString, eMin, SetEditable(false).HSizePosZ(64, 4).TopPosZ(356, 19))
ITEM(Label, dv___39, SetLabel(t_("Sensitivity")).LeftPosZ(136, 60).TopPosZ(240, 19))
ITEM(LabelBox, dv___40, SetLabel(t_("Statistical data")).HSizePosZ(0, 4).TopPosZ(329, 24))
ITEM(Label, dv___41, SetLabel(t_("RMS:")).LeftPosZ(4, 56).TopPosZ(449, 19))
ITEM(EditDouble, eRMS, SetEditable(false).HSizePosZ(64, 4).TopPosZ(449, 19))
ITEM(Label, dv___43, SetLabel(t_("Min:")).HSizePosZ(4, 144).TopPosZ(401, 19))
ITEM(EditString, eMin, SetEditable(false).HSizePosZ(64, 4).TopPosZ(401, 19))
ITEM(EditIntSpin, sgDeg, Max(5).Min(2).LeftPosZ(240, 36).TopPosZ(184, 19))
ITEM(EditIntSpin, sgOrder, Min(0).LeftPosZ(80, 28).TopPosZ(184, 19))
ITEM(Label, dv___47, SetLabel(t_("Order:")).LeftPosZ(44, 36).TopPosZ(184, 19))
ITEM(Label, dv___48, SetLabel(t_("Deg:")).LeftPosZ(212, 28).TopPosZ(184, 19))
ITEM(Option, opDerivative, SetLabel(t_("Der")).LeftPosZ(4, 36).TopPosZ(164, 19))
ITEM(EditIntSpin, derOrder, Max(2).Min(1).LeftPosZ(80, 28).TopPosZ(164, 19))
ITEM(Label, dv___51, SetLabel(t_("Order:")).LeftPosZ(44, 36).TopPosZ(164, 19))
ITEM(EditIntSpin, derAccuracy, Max(8).Min(2).LeftPosZ(168, 36).TopPosZ(164, 19))
ITEM(Label, dv___53, SetLabel(t_("Accuracy:")).LeftPosZ(116, 48).TopPosZ(164, 19))
ITEM(EditIntSpin, sgSize, Min(5).LeftPosZ(168, 36).TopPosZ(184, 19))
ITEM(Label, dv___55, SetLabel(t_("W. Size:")).LeftPosZ(116, 48).TopPosZ(184, 19))
END_LAYOUT
LAYOUT(ProcessingTabOpLeft, 428, 328)

File diff suppressed because it is too large Load diff

View file

@ -34,9 +34,9 @@ ctrl ScatterCtrl {
Font SetLabelsFont;
Color SetLabelsColor = :Black;
Color SetAxisColor = :Black;
int SetAxisWidth = 6;
double SetAxisWidth = 0.5;
Color SetGridColor = :Color(102,102,102);
int SetGridWidth = 1;
double SetGridWidth = 1;
bool ShowHGrid = true;
bool ShowVGrid = true;
bool ShowInfo = true;