-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_registro.cpp
137 lines (102 loc) · 4.54 KB
/
main_registro.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#include "mainwindow.hpp"
#include "ui_mainwindow.h"
void MainWindow::on_showHistButton_clicked()
{
// Obtengo los datos de la base de datos entre las fechas
int fermentador = ui->numberFermHistoric->currentText().toInt();
QDateTime f1, f2;
f1 = ui->fecha1Historico->dateTime();
f2 = ui->fecha2Historico->dateTime();
QList<historic_record> lista = db->getHistory(fermentador, f1, f2);
crearGraficoHistorico();
int tam = lista.size();
double inf, max;
inf = lista[0].ti;
max = lista[tam-1].ti;
#ifdef DEBUG
qDebug()<< "Tamaño de lista recibida: "<<tam;
qDebug()<< "Current TIMESTAMP ="<<QDateTime::currentDateTime().toTime_t();
qDebug()<< "Limite Inferior ="<<f1.toTime_t()<<" Fecha = "<<f1.toString();
qDebug()<< "Limite Superior ="<<f2.toTime_t()<<" Fecha = "<<f2.toString();
#endif
ui->plot_historico->xAxis->setRangeLower(inf);
ui->plot_historico->xAxis->setRangeUpper(max);
for(int i = 0; i<tam; i++)
{
ui->plot_historico->graph(0)->addData(lista[i].ti, lista[i].value);
#ifdef DEBUG
qDebug() << "Graficando Historico X="<<lista[i].ti<<" Y="<<lista[i].value;
#endif
}
ui->plot_historico->xAxis->rescale();
ui->plot_historico->rescaleAxes();
ui->plot_historico->replot();
}
void MainWindow::crearGraficoHistorico()
{
ui->plot_historico->setNotAntialiasedElements(QCP::aeAll); // used for higher performance (see QCustomPlot real time example)
QFont font;
font.setStyleStrategy(QFont::NoAntialias);
ui->plot_historico->xAxis->setTickLabelFont(font);
ui->plot_historico->yAxis->setTickLabelFont(font);
ui->plot_historico->legend->setFont(font);
ui->plot_historico->yAxis->setAutoTickStep(false); // User can change tick step with a spin box
ui->plot_historico->xAxis->grid()->setSubGridVisible(true);
ui->plot_historico->yAxis->grid()->setSubGridVisible(true);
ui->plot_historico->xAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
ui->plot_historico->yAxis->setUpperEnding(QCPLineEnding::esSpikeArrow);
ui->plot_historico->setInteraction(QCP::iRangeDrag, true);
ui->plot_historico->setInteraction(QCP::iRangeZoom, true);
ui->plot_historico->clearGraphs();
ui->plot_historico->clearItems();
// Remove everything from the plot
ui->plot_historico->yAxis->setTickStep(10); // Set tick step according to user spin box
ui->plot_historico->yAxis->setRange(-10.00, 40.00); // Set lower and upper plot range
//ui->plot_historico->xAxis->setRange(0, NUMBER_OF_POINTS); // Set x axis range for specified number of points
ui->plot_historico->xAxis->setTickLabelType(QCPAxis::ltDateTime); // Labl coordinates along the X axis as the Date and Time
ui->plot_historico->xAxis->setDateTimeFormat("dd-MM-yy hh:mm:ss"); // Set the date and time format
ui->plot_historico->xAxis->setLabel("Tiempo");
ui->plot_historico->yAxis->setLabel("Temperatura ( ºC )");
ui->plot_historico->addGraph();
}
/******************************************************************************************************************/
/* Save a JPG image of the plot to current EXE directory */
/******************************************************************************************************************/
void MainWindow::on_saveJPGButton_clicked()
{
QString fileName = QFileDialog::getSaveFileName((QWidget* )0, "Exportar Grafico", QString(), "*.jpg");
if (QFileInfo(fileName).suffix().isEmpty())
{
fileName.append(".jpg");
}
fileName = QFileInfo(fileName).baseName();
// ui->plot->saveBmp();
// ui->plot->savePdf();
ui->plot->saveJpg(fileName);
}
/******************************************************************************************************************/
/************************ PAGINA DE CALIBRACION *****************/
void MainWindow::on_signal1Check_clicked(bool checked)
{
habilitado[0] = checked;
}
void MainWindow::on_signal2Check_clicked(bool checked)
{
habilitado[1] = checked;
}
void MainWindow::on_signal3Check_clicked(bool checked)
{
habilitado[2] = checked;
}
void MainWindow::on_signal4Check_clicked(bool checked)
{
habilitado[3] = checked;
}
void MainWindow::on_signal5Check_clicked(bool checked)
{
habilitado[4] = checked;
}
void MainWindow::on_signal6Check_clicked(bool checked)
{
habilitado[5] = checked;
}