mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
ScatterCtrl: Added histogram
git-svn-id: svn://ultimatepp.org/upp/trunk@13747 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ebd3e1c303
commit
6e683934d7
5 changed files with 116 additions and 21 deletions
|
|
@ -113,10 +113,16 @@ ProcessingTab::ProcessingTab()
|
|||
CtrlLayout(tabBestFitRight);
|
||||
splitterTabBestFit.Horz(tabBestFitLeft.SizePos(), tabBestFitRight.SizePos());
|
||||
splitterTabBestFit.SetPos(6000, 0);
|
||||
CtrlLayout(tabHistLeft);
|
||||
CtrlLayout(tabHistRight);
|
||||
splitterTabHist.Horz(tabHistLeft.SizePos(), tabHistRight.SizePos());
|
||||
splitterTabHist.SetPos(8000, 0);
|
||||
|
||||
tab.Add(splitterTabFit.SizePos(), t_("Processing"));
|
||||
tab.Add(splitterTabFreq.SizePos(), t_("Frequency"));
|
||||
tab.Add(splitterTabOp.SizePos(), t_("Operations"));
|
||||
tab.Add(splitterTabBestFit.SizePos(), t_("Best fit"));
|
||||
tab.Add(splitterTabHist.SizePos(), t_("Histogram"));
|
||||
tab.WhenSet = THISBACK(OnSet);
|
||||
|
||||
tabFreqRight.butFFT.WhenAction = THISBACK(OnFFT);
|
||||
|
|
@ -177,7 +183,18 @@ ProcessingTab::ProcessingTab()
|
|||
tabBestFitRight.butFit.Tip(t_("It tries to fit the series with the supported equations"));
|
||||
tabBestFitRight.butFit.WhenPush = THISBACK(OnFit);
|
||||
|
||||
tabFreqFirst = tabOpFirst = tabBestFitFirst = true;
|
||||
tabHistRight.axis.Add(t_("X"));
|
||||
tabHistRight.axis.Add(t_("Y"));
|
||||
tabHistRight.axis.SetIndex(1);
|
||||
tabHistRight.axis.WhenAction = THISBACK(OnSet);
|
||||
tabHistRight.butHist <<= THISBACK(OnHist);
|
||||
tabHistRight.numVals <<= 30;
|
||||
tabHistRight.valNormalize <<= 100;
|
||||
|
||||
//tabHistRight.opNormalize.WhenAction = [&] {tabHistRight.valNormalize.Enable(~tabHistRight.opNormalize);};
|
||||
//tabHistRight.opNormalize.WhenAction();
|
||||
|
||||
tabFreqFirst = tabOpFirst = tabBestFitFirst = tabHistFirst = true;
|
||||
avgFirst = linearFirst = cuadraticFirst = cubicFirst = sinusFirst = sinusTendFirst = splineFirst = true;
|
||||
|
||||
exclamationOpened = false;
|
||||
|
|
@ -241,43 +258,43 @@ void ProcessingTab::OnOp()
|
|||
if (data.IsParam() || data.IsExplicit())
|
||||
return;
|
||||
|
||||
if (tabFitRight.opAverage && avgFirst) {
|
||||
if (~tabFitRight.opAverage && avgFirst) {
|
||||
double r2;
|
||||
average.Fit(data, r2);
|
||||
avgFirst = false;
|
||||
}
|
||||
if (tabFitRight.opLinear && linearFirst) {
|
||||
if (~tabFitRight.opLinear && linearFirst) {
|
||||
if (linear.Fit(data, r2Linear) < 0) {
|
||||
tabFitRight.opLinear = false;
|
||||
tabFitRight.opLinear <<= false;
|
||||
tabFitRight.opLinear.Enable(false);
|
||||
} else
|
||||
linearFirst = false;
|
||||
}
|
||||
if (tabFitRight.opCuadratic && cuadraticFirst) {
|
||||
if (~tabFitRight.opCuadratic && cuadraticFirst) {
|
||||
cuadratic.GuessCoeff(data);
|
||||
if (cuadratic.Fit(data, r2Cuadratic) < 0) {
|
||||
tabFitRight.opCuadratic = false;
|
||||
tabFitRight.opCuadratic <<= false;
|
||||
tabFitRight.opCuadratic.Enable(false);
|
||||
} else
|
||||
cuadraticFirst = false;
|
||||
}
|
||||
if (tabFitRight.opCubic && cubicFirst) {
|
||||
if (~tabFitRight.opCubic && cubicFirst) {
|
||||
cubic.GuessCoeff(data);
|
||||
if (cubic.Fit(data, r2Cubic) < 0) {
|
||||
tabFitRight.opCubic = false;
|
||||
tabFitRight.opCubic <<= false;
|
||||
tabFitRight.opCubic.Enable(false);
|
||||
} else
|
||||
cubicFirst = false;
|
||||
}
|
||||
if (tabFitRight.opSinus && sinusFirst) {
|
||||
if (~tabFitRight.opSinus && sinusFirst) {
|
||||
sinus.GuessCoeff(data);
|
||||
if (sinus.Fit(data, r2Sinus) < 0) {
|
||||
tabFitRight.opSinus = false;
|
||||
tabFitRight.opSinus <<= false;
|
||||
tabFitRight.opSinus.Enable(false);
|
||||
} else
|
||||
sinusFirst = false;
|
||||
}
|
||||
if (tabFitRight.opSinusTend && sinusTendFirst) {
|
||||
if (~tabFitRight.opSinusTend && sinusTendFirst) {
|
||||
DataXRange dataXRange;
|
||||
dataXRange.Init(data, Null, Null);
|
||||
double r2SinusTendBest = Null;
|
||||
|
|
@ -294,7 +311,7 @@ void ProcessingTab::OnOp()
|
|||
sinusTendBest = sinusTend;
|
||||
}
|
||||
if (IsNull(r2SinusTendBest)) {
|
||||
tabFitRight.opSinusTend = false;
|
||||
tabFitRight.opSinusTend <<= false;
|
||||
tabFitRight.opSinusTend.Enable(false);
|
||||
} else {
|
||||
splineFirst = false;
|
||||
|
|
@ -302,9 +319,9 @@ void ProcessingTab::OnOp()
|
|||
sinusTend = sinusTendBest;
|
||||
}
|
||||
}
|
||||
if (tabFitRight.opSpline && splineFirst) {
|
||||
if (~tabFitRight.opSpline && splineFirst) {
|
||||
if (spline.Fit(data) < 0) {
|
||||
tabFitRight.opSpline = false;
|
||||
tabFitRight.opSpline <<= false;
|
||||
tabFitRight.opSpline.Enable(false);
|
||||
} else
|
||||
splineFirst = false;
|
||||
|
|
@ -329,7 +346,6 @@ void ProcessingTab::OnOp()
|
|||
OnShowEquation();
|
||||
}
|
||||
|
||||
|
||||
void ProcessingTab::OnAutoSensSector()
|
||||
{
|
||||
if (tabFitLeft.scatter.IsDeletedDataSource(0))
|
||||
|
|
@ -525,7 +541,7 @@ void ProcessingTab::OnSet()
|
|||
return;
|
||||
DataSource &data = tabFitLeft.scatter.GetDataSource(0);
|
||||
|
||||
if (tabFreqFirst && tab.Get() == 1) {
|
||||
if (tabFreqFirst && tab.IsAt(splitterTabFreq)) {
|
||||
tabFreqFirst = false;
|
||||
if (data.IsParam() || data.IsExplicit()) {
|
||||
tabFreqLeft.comments.SetText(t_("Impossible to calculate FFT from a not sampled series"));
|
||||
|
|
@ -551,7 +567,7 @@ void ProcessingTab::OnSet()
|
|||
tabFreqLeft.comments.SetText("");
|
||||
tabFreqRight.samplingTime = (maxdT + mindT)/2.;
|
||||
}
|
||||
} else if (tabOpFirst && tab.Get() == 2) {
|
||||
} else if (tabOpFirst && tab.IsAt(splitterTabOp)) {
|
||||
if (pscatter->IsDeletedDataSource(id))
|
||||
return;
|
||||
|
||||
|
|
@ -586,7 +602,7 @@ void ProcessingTab::OnSet()
|
|||
tabOpLeft.scatter.SetXYMin(pscatter->GetXMin(), primary ? pscatter->GetYMin() : pscatter->GetY2Min());
|
||||
|
||||
tabOpLeft.scatter.ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg().SetMouseHandlingLinked(true, true);
|
||||
} else if (tabBestFitFirst && tab.Get() == 3) {
|
||||
} else if (tabBestFitFirst && tab.IsAt(splitterTabBestFit)) {
|
||||
if (pscatter->IsDeletedDataSource(id))
|
||||
return;
|
||||
|
||||
|
|
@ -610,6 +626,23 @@ void ProcessingTab::OnSet()
|
|||
tabBestFitLeft.scatter.SetXYMin(pscatter->GetXMin(), primary ? pscatter->GetYMin() : pscatter->GetY2Min());
|
||||
|
||||
tabBestFitLeft.scatter.ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg().SetMouseHandlingLinked(true, true);
|
||||
} else if (tab.IsAt(splitterTabHist)) {
|
||||
//tabHistFirst = false;
|
||||
if (data.IsParam() || data.IsExplicit()) {
|
||||
tabHistLeft.comments.SetText(t_("Impossible to calculate histogram from a not sampled series"));
|
||||
tabHistRight.butHist.Enable(false);
|
||||
} else if (data.GetCount() < 5) {
|
||||
tabHistLeft.comments.SetText(t_("Insufficient data to calculate histogram"));
|
||||
tabHistRight.butHist.Enable(false);
|
||||
} else {
|
||||
if (~tabHistRight.axis == t_("Y")) {
|
||||
tabHistRight.minVal <<= data.MinY();
|
||||
tabHistRight.maxVal <<= data.MaxY();
|
||||
} else {
|
||||
tabHistRight.minVal <<= data.MinX();
|
||||
tabHistRight.maxVal <<= data.MaxX();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -738,4 +771,38 @@ void ProcessingTab::OnFFT()
|
|||
tabFreqLeft.comments.SetText(errText);
|
||||
}
|
||||
|
||||
void ProcessingTab::OnHist() {
|
||||
tabHistLeft.scatter.RemoveAllSeries();
|
||||
|
||||
if (tabFitLeft.scatter.IsDeletedDataSource(0))
|
||||
return;
|
||||
DataSource &data = tabFitLeft.scatter.GetDataSource(0);
|
||||
|
||||
double minVal = ~tabHistRight.minVal;
|
||||
double maxVal = ~tabHistRight.maxVal;
|
||||
if (minVal >= maxVal) {
|
||||
Exclamation(Format(t_("Min val %d has to be lower than Max val %f"), minVal, maxVal));
|
||||
return;
|
||||
}
|
||||
int numVals = ~tabHistRight.numVals;
|
||||
bool normalize = ~tabHistRight.opNormalize;
|
||||
double valNormalize = ~tabHistRight.valNormalize;
|
||||
bool isY = ~tabHistRight.axis == t_("Y");
|
||||
|
||||
histogram.Create(data, minVal, maxVal, numVals, isY).Accumulative(~tabHistRight.opAccumulative);
|
||||
|
||||
if (normalize)
|
||||
histogram.Normalize(valNormalize);
|
||||
|
||||
String legend = tabFitLeft.scatter.GetLegend(0) + String("-") + t_("Histogram");
|
||||
tabHistLeft.scatter.AddSeries(histogram).Legend(legend).Units("#", isY ? tabFitLeft.scatter.GetUnitsY(0) : tabFitLeft.scatter.GetUnitsX(0));
|
||||
tabHistLeft.scatter.ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg().SetMouseHandlingLinked(true, true);
|
||||
tabHistLeft.scatter.SetLabelX(isY ? tabFitLeft.scatter.GetLegend(0) : tabFitLeft.scatter.GetLabelX());
|
||||
tabHistLeft.scatter.SetLabelY(t_("Number"));
|
||||
tabHistLeft.scatter.ZoomToFit(true, true);
|
||||
double ymax = tabHistLeft.scatter.GetYMax();
|
||||
tabHistLeft.scatter.SetXYMin(Null, 0);
|
||||
tabHistLeft.scatter.SetRange(Null, ymax);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -227,7 +227,6 @@ private:
|
|||
GeneralTab general;
|
||||
};
|
||||
|
||||
|
||||
class ProcessingTab : public WithProcessingTab<StaticRect> {
|
||||
public:
|
||||
typedef ProcessingTab CLASSNAME;
|
||||
|
|
@ -247,6 +246,7 @@ public:
|
|||
void OnSet();
|
||||
void OnUpdateSensitivity();
|
||||
void OnFit();
|
||||
void OnHist();
|
||||
|
||||
private:
|
||||
ScatterCtrl* pscatter;
|
||||
|
|
@ -264,6 +264,9 @@ private:
|
|||
WithProcessingTabBestFitLeft<StaticRect> tabBestFitLeft;
|
||||
WithProcessingTabBestFitRight<StaticRect> tabBestFitRight;
|
||||
Splitter splitterTabBestFit;
|
||||
WithProcessingTabHistogramLeft<StaticRect> tabHistLeft;
|
||||
WithProcessingTabHistogramRight<StaticRect> tabHistRight;
|
||||
Splitter splitterTabHist;
|
||||
|
||||
void ArrayCopy();
|
||||
void ArraySelect();
|
||||
|
|
@ -274,7 +277,7 @@ private:
|
|||
|
||||
bool avgFirst, linearFirst, cuadraticFirst, cubicFirst, sinusFirst, sinusTendFirst, splineFirst;
|
||||
double r2Linear, r2Cuadratic, r2Cubic, r2Sinus, r2SinusTend;
|
||||
bool tabFreqFirst, tabOpFirst, tabBestFitFirst;
|
||||
bool tabFreqFirst, tabOpFirst, tabBestFitFirst, tabHistFirst;
|
||||
|
||||
Vector<Pointf> fft;
|
||||
AvgEquation average;
|
||||
|
|
@ -288,6 +291,8 @@ private:
|
|||
DataXRange dataXRange;
|
||||
bool exclamationOpened;
|
||||
double newWidthMax, newWidthMin, newWidthMovAvg;
|
||||
|
||||
Histogram histogram;
|
||||
};
|
||||
|
||||
class ProcessingDlg : public TopWindow {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
#include <plugin/jpg/jpg.h>
|
||||
#include <PdfDraw/PdfDraw.h>
|
||||
#include <GridCtrl/GridCtrl.h>
|
||||
#include <plugin/Eigen/Eigen.h>
|
||||
#include <ScatterDraw/Histogram.h>
|
||||
#include <ScatterDraw/Pedantic.h>
|
||||
|
||||
#include "PopUpText.h"
|
||||
|
|
|
|||
|
|
@ -287,6 +287,27 @@ LAYOUT(ProcessingTabBestFitRight, 332, 428)
|
|||
ITEM(Label, dv___7, SetLabel(t_("User equation:")).LeftPosZ(4, 88).BottomPosZ(5, 19))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(ProcessingTabHistogramLeft, 428, 420)
|
||||
ITEM(ScatterCtrl, scatter, SetPlotAreaLeftMargin(60).SetPlotAreaBottomMargin(40).ShowContextMenu(true).ShowPropertiesDlg(true).ShowProcessDlg(true).ShowButtons(true).HSizePosZ(0, 0).VSizePosZ(0, 20))
|
||||
ITEM(Label, comments, HSizePosZ(0, 4).BottomPosZ(1, 19))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(ProcessingTabHistogramRight, 124, 424)
|
||||
ITEM(Label, dv___0, SetLabel(t_("Max:")).HSizePosZ(4, 68).TopPosZ(96, 19))
|
||||
ITEM(EditDouble, maxVal, HSizePosZ(56, 4).TopPosZ(96, 19))
|
||||
ITEM(Label, dv___2, SetLabel(t_("Min:")).HSizePosZ(4, 68).TopPosZ(72, 19))
|
||||
ITEM(EditDouble, minVal, HSizePosZ(56, 4).TopPosZ(72, 19))
|
||||
ITEM(Label, dv___4, SetLabel(t_("Number: ")).HSizePosZ(4, 68).TopPosZ(48, 19))
|
||||
ITEM(EditInt, numVals, Min(1).HSizePosZ(56, 4).TopPosZ(48, 19))
|
||||
ITEM(Label, dv___6, SetLabel(t_("Axis")).HSizePosZ(4, 4).TopPosZ(4, 19))
|
||||
ITEM(DropList, axis, HSizePosZ(4, 4).TopPosZ(24, 19))
|
||||
ITEM(Button, butHist, SetLabel(t_("Histogram")).HSizePosZ(4, 4).TopPosZ(200, 20))
|
||||
ITEM(Label, dv___9, SetLabel(t_("Val:")).LeftPosZ(12, 36).TopPosZ(164, 19))
|
||||
ITEM(EditDouble, valNormalize, Min(0).HSizePosZ(56, 12).TopPosZ(164, 19))
|
||||
ITEM(OptionBox, opNormalize, AutoBox(true).SetLabel(t_("Normalize")).HSizePosZ(4, 4).TopPosZ(144, 48))
|
||||
ITEM(Option, opAccumulative, SetLabel(t_("Accumulative")).LeftPosZ(4, 88).TopPosZ(120, 16))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(FontSelector, 208, 76)
|
||||
ITEM(DropList, face, LeftPosZ(4, 140).TopPosZ(4, 19))
|
||||
ITEM(DropList, height, LeftPosZ(148, 54).TopPosZ(4, 19))
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@ file
|
|||
ScatterCtrl.h,
|
||||
ScatterCtrlX.cpp,
|
||||
Properties.cpp,
|
||||
Properties.h,
|
||||
Processing.cpp,
|
||||
Properties.h,
|
||||
Data.cpp,
|
||||
PopUpText.cpp,
|
||||
PopUpText.h,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue