diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/cpp/lineGraph.cpp (renamed from src/cpp/hrGraph.cpp) | 46 | ||||
-rw-r--r-- | src/cpp/lineGraph.h (renamed from src/cpp/hrGraph.h) | 22 | ||||
-rw-r--r-- | src/graphs/HrGraph.qml | 2 | ||||
-rw-r--r-- | src/main.cpp | 4 |
5 files changed, 38 insertions, 38 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 881c3ba..44c8ba1 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -add_library(asteroid-health main.cpp cpp/hrGraph.cpp cpp/hrGraph.h resources.qrc) +add_library(asteroid-health main.cpp cpp/lineGraph.cpp cpp/lineGraph.h resources.qrc) set_target_properties(asteroid-health PROPERTIES PREFIX "") target_link_libraries(asteroid-health PUBLIC diff --git a/src/cpp/hrGraph.cpp b/src/cpp/lineGraph.cpp index ccec424..be6fd86 100644 --- a/src/cpp/hrGraph.cpp +++ b/src/cpp/lineGraph.cpp @@ -28,7 +28,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "hrGraph.h" +#include "lineGraph.h" #include <QPainter> #include <QDate> @@ -38,14 +38,14 @@ #include <QStandardPaths> #include <QPointF> -HrGraph::HrGraph() +LineGraph::LineGraph() { setFlag(ItemHasContents, true); setAntialiasing(true); setRenderTarget(QQuickPaintedItem::FramebufferObject); } -void HrGraph::paint(QPainter *painter) +void LineGraph::paint(QPainter *painter) { if (!m_fileLoadStatus) { return; @@ -53,15 +53,15 @@ void HrGraph::paint(QPainter *painter) int j = m_filedata.count(); QPointF points[j]; if (!graphRelative) { - minHrValue = 0; + minValue = 0; } - float valueDelta = maxHrValue - minHrValue; + float valueDelta = maxValue - minValue; float timeDelta = maxTime - minTime; float calculatedValue = 0; float calculatedTimeSeconds = 0; for(int i = 0; i < j; i++) { calculatedTimeSeconds = (m_filedata[i].x() - minTime)/timeDelta; - calculatedValue = 1 - (m_filedata[i].y() - minHrValue)/valueDelta; + calculatedValue = 1 - (m_filedata[i].y() - minValue)/valueDelta; points[i] = QPointF(m_lineWidth + calculatedTimeSeconds*(width()-2*m_lineWidth), m_lineWidth + calculatedValue*(height()-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; @@ -74,7 +74,7 @@ void HrGraph::paint(QPainter *painter) painter->drawPolyline(points,j); } -void HrGraph::loadGraphData(QVariant fileDataInput) { +void LineGraph::loadGraphData(QVariant fileDataInput) { qDebug() << "loadGraphData called"; QList<QVariant> fileDataAsList = fileDataInput.toList(); if (fileDataAsList.count() < 1) { @@ -84,56 +84,56 @@ void HrGraph::loadGraphData(QVariant fileDataInput) { int j = fileDataAsList.count(); minTime = fileDataAsList[0].toPoint().x(); maxTime = fileDataAsList[j-1].toPoint().x(); - minHrValue = fileDataAsList[0].toPoint().y(); - maxHrValue = minHrValue; + minValue = fileDataAsList[0].toPoint().y(); + maxValue = minValue; m_filedata.clear(); for(int i = 0; i < j; i++) { m_filedata.append(fileDataAsList[i].toPoint()); - if (minHrValue > m_filedata[i].y()) minHrValue = m_filedata[i].y(); - if (maxHrValue < m_filedata[i].y()) maxHrValue = m_filedata[i].y(); + if (minValue > m_filedata[i].y()) minValue = m_filedata[i].y(); + if (maxValue < m_filedata[i].y()) maxValue = m_filedata[i].y(); } emit loadingDone(); update(); } -void HrGraph::setLineColor(QColor color) { +void LineGraph::setLineColor(QColor color) { m_color = color; update(); } -QColor HrGraph::lineColor() { +QColor LineGraph::lineColor() { return m_color; } -void HrGraph::setLineWidth(float width) { +void LineGraph::setLineWidth(float width) { m_lineWidth = width; update(); } -float HrGraph::lineWidth() { +float LineGraph::lineWidth() { return m_lineWidth; } -int HrGraph::getMaxHrValue() { - return maxHrValue; +int LineGraph::getMaxValue() { + return maxValue; } -int HrGraph::getMinHrValue() { - return minHrValue; +int LineGraph::getMinValue() { + return minValue; } -QDateTime HrGraph::getMaxTime() { +QDateTime LineGraph::getMaxTime() { return QDateTime::fromSecsSinceEpoch(maxTime); } -QDateTime HrGraph::getMinTime() { +QDateTime LineGraph::getMinTime() { return QDateTime::fromSecsSinceEpoch(minTime); } -bool HrGraph::relative() { +bool LineGraph::relative() { return graphRelative; } -void HrGraph::setRelative(bool newRelative) { +void LineGraph::setRelative(bool newRelative) { graphRelative = newRelative; } diff --git a/src/cpp/hrGraph.h b/src/cpp/lineGraph.h index 63d2f17..59cbb68 100644 --- a/src/cpp/hrGraph.h +++ b/src/cpp/lineGraph.h @@ -27,8 +27,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef HRGRAPH_H -#define HRGRAPH_H +#ifndef LINEGRAPH_H +#define LINEGRAPH_H #include <QQuickPaintedItem> #include <QPixmap> @@ -36,21 +36,21 @@ #include <QVector> #include <QPointF> -class HrGraph : public QQuickPaintedItem +class LineGraph : public QQuickPaintedItem { Q_OBJECT Q_PROPERTY(float lineWidth READ lineWidth WRITE setLineWidth) Q_PROPERTY(QColor lineColor READ lineColor WRITE setLineColor NOTIFY lineColorChanged) - Q_PROPERTY(int maxValue READ getMaxHrValue NOTIFY loadingDone) - Q_PROPERTY(int minValue READ getMinHrValue NOTIFY loadingDone) + Q_PROPERTY(int maxValue READ getMaxValue NOTIFY loadingDone) + Q_PROPERTY(int minValue READ getMinValue NOTIFY loadingDone) Q_PROPERTY(QDateTime maxTime READ getMaxTime NOTIFY loadingDone) Q_PROPERTY(QDateTime minTime READ getMinTime NOTIFY loadingDone) Q_PROPERTY(bool relativeMode READ relative WRITE setRelative) public: Q_INVOKABLE void loadGraphData(QVariant fileDataInput); - HrGraph(); + LineGraph(); void paint(QPainter *painter) override; signals: @@ -62,8 +62,8 @@ public slots: void setLineWidth(float width); QColor lineColor(); void setLineColor(QColor color); - int getMaxHrValue(); - int getMinHrValue(); + int getMaxValue(); + int getMinValue(); QDateTime getMaxTime(); QDateTime getMinTime(); bool relative(); @@ -77,11 +77,11 @@ private: QPixmap m_pixmap; QList<QPointF> m_filedata; bool m_fileLoadStatus; - int minHrValue = 0; - int maxHrValue = 0; + int minValue = 0; + int maxValue = 0; int minTime; int maxTime; bool graphRelative; }; -#endif // ICON_H +#endif // LINEGRAPH_H diff --git a/src/graphs/HrGraph.qml b/src/graphs/HrGraph.qml index 84a408e..ac5113e 100644 --- a/src/graphs/HrGraph.qml +++ b/src/graphs/HrGraph.qml @@ -81,7 +81,7 @@ Item { } } } - HeartrateGraph { + LineGraph { id: hrGraph anchors { left: markerParent.right diff --git a/src/main.cpp b/src/main.cpp index 48fa468..57f1353 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,10 +18,10 @@ #include <QtQml> #include <asteroidapp.h> -#include "cpp/hrGraph.h" +#include "cpp/lineGraph.h" int main(int argc, char *argv[]) { - qmlRegisterType<HrGraph>("org.asteroid.health", 1, 0, "HeartrateGraph"); + qmlRegisterType<LineGraph>("org.asteroid.health", 1, 0, "LineGraph"); return AsteroidApp::main(argc, argv); } |