-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.cpp
More file actions
89 lines (73 loc) · 1.78 KB
/
gui.cpp
File metadata and controls
89 lines (73 loc) · 1.78 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include "gui.h"
#include "ui_gui.h"
Gui::Gui(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::Gui)
{
ui->setupUi(this);
SetTempChart();
}
Gui::~Gui()
{
delete ui;
}
void Gui::SetTempChart()
{
chart->legend()->hide();
chart->addSeries(tempSeries);
chart->createDefaultAxes();
chart->axisX()->setRange(0,10);
chart->axisX()->hide();
chart->axisY()->setRange(-20,50);
chart->setTitle("Temperatur (°C)");
chart->setAnimationOptions(QChart::AllAnimations);
chartView->setRenderHint(QPainter::Antialiasing);
setCentralWidget(chartView);
resize(400, 300);
}
void Gui::SetLightChart()
{
chart->legend()->hide();
chart->addSeries(lightSeries);
chart->createDefaultAxes();
chart->axisX()->setRange(0,10);
chart->axisX()->hide();
chart->axisY()->setRange(0,1000);
chart->setTitle("Light intensity (Lux)");
chart->setAnimationOptions(QChart::AllAnimations);
chartView->setRenderHint(QPainter::Antialiasing);
setCentralWidget(chartView);
resize(400, 300);
}
void Gui::AddTemp(int data){
tempSeries->append(tempCount,data);
if(tempCount>10){
chart->axisX()->setRange(tempCount-10,tempCount);
}
}
void Gui::DataInput(int id, int data){
if(id == 1){
tempCount++;
AddTemp(data);
}
if(id == 2){
lightCount++;
AddLight(data);
}
}
void Gui::AddLight(int data){
lightSeries->append(lightCount,data);
if(lightCount>10){
chart->axisX()->setRange(lightCount-10,lightCount);
}
}
void Gui::on_actionTempuratur_triggered()
{
tempCount=0;
SetLightChart();
}
void Gui::on_actionLight_triggered()
{
lightCount=0;
SetTempChart();
}