-
Notifications
You must be signed in to change notification settings - Fork 14
/
DataPlotWidget.h
49 lines (37 loc) · 1.01 KB
/
DataPlotWidget.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
* @author fiachra & tom
*/
#pragma once
#include <deque>
#include <QComboBox>
#include <QHBoxLayout>
#include <QLabel>
#include <QPainter>
#include <QPushButton>
#include <QSignalMapper>
#include <QVBoxLayout>
#include <QWidget>
class QPaintEvent;
class DataPlotWidget : public QWidget {
Q_OBJECT;
public:
DataPlotWidget(QWidget* parent = 0);
virtual ~DataPlotWidget() = default;
void updatePlot(const std::vector<std::pair<std::string, float>>& plotVals);
void setDataLength(int newLength);
void resetPlot();
int plotWidth = 640;
int plotHeight = 240;
static constexpr int kInitialPlotLength = 100;
private:
QPainter painter;
void paintEvent(QPaintEvent* event) override;
int getPlotY(float val, float dataMin, float dataMax);
void drawDataPlot();
void resizeEvent(QResizeEvent* event) override;
int maxPlotLength = kInitialPlotLength;
int currentIndex = 0;
int currentCount = 0;
int colorCounter = 0;
std::map<std::string, std::pair<QColor, std::vector<float>>> dataArray;
};