mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-25 07:57:19 +00:00
Cosmetic changes
* fix invalid graph painting - for some reasons graphs are not normed as expected. * fix cppcheck warnings related to no default values
This commit is contained in:
parent
453d4d5149
commit
3a6033e676
@ -90,14 +90,14 @@ void GraphicalItemHelper::paintGraph(const float &value)
|
|||||||
// default norms
|
// default norms
|
||||||
float normX
|
float normX
|
||||||
= static_cast<float>(m_width) / static_cast<float>(m_values.count());
|
= static_cast<float>(m_width) / static_cast<float>(m_values.count());
|
||||||
float normY = static_cast<float>(m_height) / 1.5f;
|
float normY = static_cast<float>(m_height - 1);
|
||||||
// paint graph
|
// paint graph
|
||||||
for (int i = 0; i < m_values.count() - 1; i++) {
|
for (int i = 0; i < m_values.count() - 1; i++) {
|
||||||
// some magic here
|
// some magic here
|
||||||
float x1 = i * normX;
|
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 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);
|
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;
|
qCDebug(LOG_LIB) << "Save value to array" << value;
|
||||||
|
|
||||||
if (m_values.count() == 0)
|
if (m_values.count() == 0)
|
||||||
m_values.append(0.0);
|
m_values.append(1.0);
|
||||||
else if (m_values.count() > m_count)
|
else if (m_values.count() > m_count)
|
||||||
m_values.removeFirst();
|
m_values.removeFirst();
|
||||||
|
|
||||||
|
@ -46,11 +46,11 @@ public:
|
|||||||
private:
|
private:
|
||||||
void storeValue(const float &value);
|
void storeValue(const float &value);
|
||||||
QGraphicsScene *m_scene = nullptr;
|
QGraphicsScene *m_scene = nullptr;
|
||||||
int m_count;
|
int m_count = 100;
|
||||||
QColor m_activeColor;
|
QColor m_activeColor;
|
||||||
QColor m_inactiveColor;
|
QColor m_inactiveColor;
|
||||||
int m_width;
|
int m_width = 100;
|
||||||
int m_height;
|
int m_height = 100;
|
||||||
// list of values which will be used to store data for graph type only
|
// list of values which will be used to store data for graph type only
|
||||||
QList<float> m_values;
|
QList<float> m_values;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user