feat: graphs now properly sized + port static graphs to c++
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <qcolor.h>
|
||||
#include <qelapsedtimer.h>
|
||||
#include <qpainterpath.h>
|
||||
#include <qquickpainteditem.h>
|
||||
|
||||
@@ -30,6 +31,15 @@ class SparklineContent : public QQuickPaintedItem {
|
||||
|
||||
void setViewportSize(qreal viewportWidth, qreal viewportHeight);
|
||||
|
||||
// How often a new sample arrives, in milliseconds. With this set the slide
|
||||
// phase is read from the sample clock rather than from `progress`, which
|
||||
// makes the wrap exact; without it the phase is the value QML supplies.
|
||||
void setSlideInterval(qreal intervalMs);
|
||||
|
||||
// Offsets the item for the slide. Kept here rather than in SparklineItem
|
||||
// because the quantization needs both stepX() and the window's dpr.
|
||||
void setSlideProgress(qreal progress);
|
||||
|
||||
[[nodiscard]] qreal stepX() const;
|
||||
|
||||
protected:
|
||||
@@ -44,12 +54,15 @@ class SparklineContent : public QQuickPaintedItem {
|
||||
bool hasData = false;
|
||||
};
|
||||
|
||||
[[nodiscard]] qreal slidePhase(qreal progress) const;
|
||||
|
||||
void invalidate();
|
||||
void rebuildIfNeeded();
|
||||
[[nodiscard]] LineGeometry buildGeometry(
|
||||
internal::CircularBuffer* buffer) const;
|
||||
void connectBuffer(internal::CircularBuffer* buffer);
|
||||
void applyGeometry();
|
||||
void onSampleArrived();
|
||||
|
||||
internal::CircularBuffer* m_line1 = nullptr;
|
||||
internal::CircularBuffer* m_line2 = nullptr;
|
||||
@@ -65,7 +78,14 @@ class SparklineContent : public QQuickPaintedItem {
|
||||
|
||||
qreal m_viewportW = 0.0;
|
||||
qreal m_viewportH = 0.0;
|
||||
// The height actually painted, snapped so the texture maps 1:1 onto device
|
||||
// rows. The plot bounds are built from this, not from the slot's height.
|
||||
qreal m_paintedH = 0.0;
|
||||
qreal m_dpr = 1.0;
|
||||
qreal m_slideIntervalMs = 0.0;
|
||||
// Restarted whenever a sample arrives, so the slide phase follows the sample
|
||||
// cadence instead of the animation's timeline.
|
||||
QElapsedTimer m_sampleClock;
|
||||
|
||||
LineGeometry m_geom1;
|
||||
LineGeometry m_geom2;
|
||||
|
||||
Reference in New Issue
Block a user