-
Notifications
You must be signed in to change notification settings - Fork 1
/
displayemotion.cpp
93 lines (78 loc) · 3.01 KB
/
displayemotion.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
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
90
91
92
93
#include "displayemotion.h"
#include "ui_displayemotion.h"
#include <iostream>
DisplayEmotion::DisplayEmotion(QWidget *parent) :
QDialog(parent),
ui(new Ui::DisplayEmotion)
{
ui->setupUi(this);
connect(this, SIGNAL(rejected()),
this, SIGNAL(pressedOK()));
ui->chart->legend->setVisible(true);
QFont legendFont = font();
legendFont.setPointSize(9);
ui->chart->legend->setFont(legendFont);
ui->chart->legend->setPositionStyle(QCPLegend::psBottomRight);
ui->chart->legend->setBrush(QBrush(QColor(255,255,255,230)));
ui->chart->addGraph();
ui->chart->graph(0)->setPen(QPen(Qt::blue));
ui->chart->graph(0)->setName("Engagement");
ui->chart->addGraph();
ui->chart->graph(1)->setPen(QPen(Qt::red));
ui->chart->graph(1)->setName("Excitement");
ui->chart->addGraph();
ui->chart->graph(2)->setPen(QPen(Qt::green));
ui->chart->graph(2)->setName("Frustration");
ui->chart->addGraph();
ui->chart->graph(3)->setPen(QPen(Qt::yellow));
ui->chart->graph(3)->setName("Meditation");
}
DisplayEmotion::~DisplayEmotion()
{
delete ui;
}
void DisplayEmotion::updateWindow(QString user, QString artist, QString track, QList< QList<float> > rawData, QList< QList<float> > stats)
{
// Update chart
QVector<float> engagementF = rawData[0].toVector();
QVector<float> excitementF = rawData[1].toVector();
QVector<float> frustrationF = rawData[2].toVector();
QVector<float> meditationF = rawData[3].toVector();
int noDataPoints = engagementF.size();
QVector<double> engagement(noDataPoints);
QVector<double> excitement(noDataPoints);
QVector<double> frustration(noDataPoints);
QVector<double> meditation(noDataPoints);
for (int n = 0 ; n < noDataPoints ; n++) {
engagement[n] = engagementF[n];
excitement[n] = excitementF[n];
frustration[n] = frustrationF[n];
meditation[n] = meditationF[n];
}
QVector<double> x(noDataPoints);
for (int n = 0 ; n < noDataPoints ; n++) {
x[n] = n;
}
ui->chart->graph(0)->setData(x, engagement);
ui->chart->graph(1)->setData(x, excitement);
ui->chart->graph(2)->setData(x, frustration);
ui->chart->graph(3)->setData(x, meditation);
ui->chart->rescaleAxes();
QString title = QString("User: %1 Track: %2 by %3" ).arg(user, track, artist);
ui->chart->setTitle(title);
ui->chart->yAxis->setRange(0,1);
ui->chart->replot();
// Update table
for (int n = 0 ; n < 4 ; n++) {
QTableWidgetItem* ave = new QTableWidgetItem(QString::number(stats[0][n]));
QTableWidgetItem* cha = new QTableWidgetItem(QString::number(stats[1][n]));
QTableWidgetItem* std = new QTableWidgetItem(QString::number(stats[2][n]));
ui->summaryTable->setItem(n, 0, ave);
ui->summaryTable->setItem(n, 1, cha);
ui->summaryTable->setItem(n, 2, std);
}
QString filename = QString("%1%2%3.jpg").arg(user, artist, track);
filename.remove(" ");
ui->chart->saveJpg(filename);
this->show();
}