diff options
author | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-30 00:06:16 +0100 |
---|---|---|
committer | Arseniy-Movshev <dodoradio@outlook.com> | 2023-05-30 00:39:52 +0100 |
commit | 94238a02c8a947593d69a6271b3fd1cf5e264be2 (patch) | |
tree | 63a1fcf33d03106b696e9e060c8a39dbd6dc63dc /qmlplugin/hrGraph.cpp | |
parent | 0d5a7b23b192194833d80540cac8c361f3de24ec (diff) |
Add some more parameters to the heartrate graph
Diffstat (limited to '')
-rw-r--r-- | qmlplugin/hrGraph.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/qmlplugin/hrGraph.cpp b/qmlplugin/hrGraph.cpp index 7540083..625300e 100644 --- a/qmlplugin/hrGraph.cpp +++ b/qmlplugin/hrGraph.cpp @@ -59,8 +59,13 @@ void HrGraph::paint(QPainter *painter) for(int i = 0; i < j; i++) { calculatedTimeSeconds = (m_filedata.at(i).time - minTime)/timeDelta; calculatedValue = 1 - (m_filedata.at(i).value - minHrValue)/valueDelta; - points[i] = QPointF(1 + calculatedTimeSeconds*(height()-2), 1 + calculatedValue*(width()-2)); //these +2 -1 are here to make sure that the graph fits within the drawn area, as it will be clipped by qt if it doesn't. + points[i] = QPointF(m_lineWidth + calculatedTimeSeconds*(height()-2*m_lineWidth), m_lineWidth + calculatedValue*(width()-2*m_lineWidth)); //these +2 -1 are here to make sure that the graph fits within the drawn area, as it will be clipped by qt if it doesn't. } + QPen pen; + pen.setWidthF(m_lineWidth); + pen.setColor(m_color); + painter->setRenderHints(QPainter::Antialiasing); + painter->setPen(pen); painter->drawPolyline(points,j); } @@ -100,3 +105,21 @@ void HrGraph::loadGraphData(QDate date) { qDebug() << "heartrate graph file loading done"; file.close(); } + +void HrGraph::setLineColor(QColor color) { + m_color = color; + update(); +} + +QColor HrGraph::lineColor() { + return m_color; +} + +void HrGraph::setLineWidth(float width) { + m_lineWidth = width; + update(); +} + +float HrGraph::lineWidth() { + return m_lineWidth; +} |