Files
Upsilon/apps/regression/graph_view.cpp
Émilie Feral c3008ca360 [apps] Improvements of MVC structure regarding curve views and ranges
Change-Id: Iec8031dbf349c34c18694dffabd02ef9c88ebf2d
2017-01-18 14:31:42 +01:00

39 lines
1.2 KiB
C++

#include "graph_view.h"
#include <assert.h>
#include <math.h>
namespace Regression {
GraphView::GraphView(Store * store, CurveViewCursor * cursor, ::BannerView * bannerView, View * cursorView) :
CurveView(store, cursor, bannerView, cursorView),
m_store(store)
{
}
void GraphView::drawRect(KDContext * ctx, KDRect rect) const {
ctx->fillRect(rect, KDColorWhite);
drawGrid(ctx, rect);
drawAxes(ctx, rect, Axis::Horizontal);
drawAxes(ctx, rect, Axis::Vertical);
drawLabels(ctx, rect, Axis::Horizontal, true);
drawLabels(ctx, rect, Axis::Vertical, true);
drawCurve(ctx, rect, nullptr, KDColorRed);
for (int index = 0; index < m_store->numberOfPairs(); index++) {
drawDot(ctx, rect, m_store->get(0,index), m_store->get(1,index), KDColorBlue, KDSize(k_dotSize, k_dotSize));
}
drawDot(ctx, rect, m_store->meanOfColumn(0), m_store->meanOfColumn(1), KDColorGreen, KDSize(k_dotSize, k_dotSize));
}
char * GraphView::label(Axis axis, int index) const {
if (axis == Axis::Vertical) {
return (char *)m_yLabels[index];
}
return (char *)m_xLabels[index];
}
float GraphView::evaluateModelWithParameter(Model * curve, float t) const {
return m_store->yValueForXValue(t);
}
}