From 3a6033e67678b6834b3ed00c1c2ae36dca4e76f9 Mon Sep 17 00:00:00 2001 From: arcan1s Date: Fri, 18 Mar 2016 16:23:53 +0300 Subject: [PATCH] Cosmetic changes * fix invalid graph painting - for some reasons graphs are not normed as expected. * fix cppcheck warnings related to no default values --- sources/awesomewidgets/graphicalitemhelper.cpp | 8 ++++---- sources/awesomewidgets/graphicalitemhelper.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/sources/awesomewidgets/graphicalitemhelper.cpp b/sources/awesomewidgets/graphicalitemhelper.cpp index b7dadc2..c7f459e 100644 --- a/sources/awesomewidgets/graphicalitemhelper.cpp +++ b/sources/awesomewidgets/graphicalitemhelper.cpp @@ -90,14 +90,14 @@ void GraphicalItemHelper::paintGraph(const float &value) // default norms float normX = static_cast(m_width) / static_cast(m_values.count()); - float normY = static_cast(m_height) / 1.5f; + float normY = static_cast(m_height - 1); // paint graph for (int i = 0; i < m_values.count() - 1; i++) { // some magic here float x1 = i * normX; - float y1 = -fabs(m_values.at(i)) * normY + 5.0f; + float y1 = -fabs(m_values.at(i)) * normY + 0.5f; float x2 = (i + 1) * normX; - float y2 = -fabs(m_values.at(i + 1)) * normY + 5.0f; + float y2 = -fabs(m_values.at(i + 1)) * normY + 0.5f; m_scene->addLine(x1, y1, x2, y2, pen); } } @@ -183,7 +183,7 @@ void GraphicalItemHelper::storeValue(const float &value) qCDebug(LOG_LIB) << "Save value to array" << value; if (m_values.count() == 0) - m_values.append(0.0); + m_values.append(1.0); else if (m_values.count() > m_count) m_values.removeFirst(); diff --git a/sources/awesomewidgets/graphicalitemhelper.h b/sources/awesomewidgets/graphicalitemhelper.h index 9e6157a..30c2dc3 100644 --- a/sources/awesomewidgets/graphicalitemhelper.h +++ b/sources/awesomewidgets/graphicalitemhelper.h @@ -46,11 +46,11 @@ public: private: void storeValue(const float &value); QGraphicsScene *m_scene = nullptr; - int m_count; + int m_count = 100; QColor m_activeColor; QColor m_inactiveColor; - int m_width; - int m_height; + int m_width = 100; + int m_height = 100; // list of values which will be used to store data for graph type only QList m_values; };