From eed0f4af9598ca7787240eab807dd1c5a05ba358 Mon Sep 17 00:00:00 2001 From: Romain Goyet Date: Tue, 21 Jun 2016 11:45:58 +0200 Subject: [PATCH] Graph: Draw axis and grid Change-Id: I06d01dfbf7f45920aa32fd5c85819c75309fbfc4 --- apps/graph/graph/graph_view.cpp | 99 +++++++++++++++++++++++++-------- apps/graph/graph/graph_view.h | 17 ++++++ 2 files changed, 93 insertions(+), 23 deletions(-) diff --git a/apps/graph/graph/graph_view.cpp b/apps/graph/graph/graph_view.cpp index 818013218..fbf6e132e 100644 --- a/apps/graph/graph/graph_view.cpp +++ b/apps/graph/graph/graph_view.cpp @@ -1,9 +1,19 @@ #include "graph_view.h" +constexpr KDColor kAxisColor = KDColorGray(0x0); +constexpr KDColor kMainGridColor = KDColorGray(0xCC); +constexpr KDColor kSecondaryGridColor = KDColorGray(0xEE); +constexpr int kNumberOfMainGridLines = 5; +constexpr int kNumberOfSecondaryGridLines = 5; + GraphView::GraphView() : View(), m_cursorView(CursorView()), - m_cursorPosition(KDPointZero) + m_cursorPosition(KDPointZero), + m_xMin(-2.0f), + m_xMax(2.0f), + m_yMin(-2.0f), + m_yMax(2.0f) { } @@ -30,29 +40,72 @@ void GraphView::layoutSubviews() { void GraphView::drawRect(KDRect rect) const { KDFillRect(rect, KDColorWhite); - KDCoordinate x_grid_step = m_frame.width/10; - KDCoordinate y_grid_step = m_frame.height/10; - KDColor gridColor = KDColorGray(0xEE); - for (KDCoordinate x=0; x