-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmainwindow.cpp
87 lines (46 loc) · 1.33 KB
/
mainwindow.cpp
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
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
#include <QDesktopWidget>
#include <QScreen>
#include <QMessageBox>
#include <QMetaEnum>
#include "gpsdatahandler.h"
#define _WIDTH 128
#define _HEIGHT 128
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
setGeometry(400, 250, _WIDTH, _HEIGHT);
this->gpsHandler = new gpsdatahandler();
this->gpsHandler->computeDistAlt();
setupDemo();
}
void MainWindow::setupDemo()
{
setupPlot(ui->customPlot);
setWindowTitle("distance-altitude graph");
statusBar()->clearMessage();
ui->customPlot->replot();
}
void MainWindow::setupPlot(QCustomPlot *customPlot)
{
QVector<double> *x = this->gpsHandler->getDistanceData();
QVector<double> *y = this->gpsHandler->getAltitudeData();
QColor plotColor(75, 75, 75, 255);
QColor backColor(175, 175, 175, 255);
customPlot->addGraph();
customPlot->graph()->setLineStyle(QCPGraph::lsLine);
customPlot->graph()->setPen(QPen(plotColor.lighter(200)));
customPlot->graph()->setBrush(QBrush(plotColor));
customPlot->setBackground(backColor);
customPlot->xAxis->setVisible(false);
customPlot->graph(0)->setData(*x, *y);
customPlot->graph(0)->rescaleAxes();
}
MainWindow::~MainWindow()
{
delete ui;
}