mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps] In CurveView, replace the virtual method evaluateModelWithParameter by a function given as parameter (to be able to call Curve view methods with different implementation of evaluateModelWithParameter)
This commit is contained in:
committed by
EmilieNumworks
parent
ea28475432
commit
ef8f5e07c2
@@ -9,9 +9,7 @@ GraphView::GraphView(Store * store, CurveViewCursor * cursor, BannerView * banne
|
||||
CurveView(store, cursor, bannerView, cursorView),
|
||||
m_store(store),
|
||||
m_xLabels{},
|
||||
m_yLabels{},
|
||||
m_slope(NAN),
|
||||
m_yIntercept(NAN)
|
||||
m_yLabels{}
|
||||
{
|
||||
}
|
||||
|
||||
@@ -22,9 +20,12 @@ void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
|
||||
drawAxes(ctx, rect, Axis::Vertical);
|
||||
drawLabels(ctx, rect, Axis::Horizontal, true);
|
||||
drawLabels(ctx, rect, Axis::Vertical, true);
|
||||
m_slope = m_store->slope();
|
||||
m_yIntercept = m_store->yIntercept();
|
||||
drawCurve(ctx, rect, nullptr, Palette::YellowDark);
|
||||
float regressionParameters[2] = {(float)m_store->slope(), (float)m_store->yIntercept()};
|
||||
drawCurve(ctx, rect, [](float abscissa, void * model, void * context) {
|
||||
float * params = (float *)model;
|
||||
return params[0]*abscissa+params[1];
|
||||
},
|
||||
regressionParameters, nullptr, Palette::YellowDark);
|
||||
for (int index = 0; index < m_store->numberOfPairs(); index++) {
|
||||
drawDot(ctx, rect, m_store->get(0,index), m_store->get(1,index), Palette::Red);
|
||||
}
|
||||
@@ -39,8 +40,4 @@ char * GraphView::label(Axis axis, int index) const {
|
||||
return (char *)m_xLabels[index];
|
||||
}
|
||||
|
||||
float GraphView::evaluateModelWithParameter(Model * curve, float t) const {
|
||||
return m_slope*t+m_yIntercept;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user