src/ChartCarbonate.cpp

Thu, 18 Aug 2022 17:07:47 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 17:07:47 +0200
changeset 398
49cf387e9070
parent 371
d03a426e0b6b
child 434
ebf4996ab396
permissions
-rw-r--r--

After brewing show final IBU on the first tab.

332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * ChartCarbonate.cpp is part of bmsapp.
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "ChartCarbonate.h"
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
18 #include "callout.h"
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "MainWindow.h"
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 ChartCarbonate::ChartCarbonate(QString code, QString name, QWidget *parent) : QDialog(parent)
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 {
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 QSqlQuery query;
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 double timestamp;
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 qDebug() << "ChartCarbonate:" << code << name;
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 QDialog* dialog = new QDialog(parent);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
30 dialog->setWindowTitle(tr("BMSapp - Carbonation ") + "\"" + name + "\"");
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 dialog->setObjectName(QString::fromUtf8("ChartCarbonate"));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 dialog->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 dialog->resize(1024, 600);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
34
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
35 QPushButton *saveButton = new QPushButton(tr("Save"));
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
36 saveButton->setAutoDefault(false);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
37 QIcon icon1;
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
38 icon1.addFile(QString::fromUtf8(":icons/silk/disk.png"), QSize(), QIcon::Normal, QIcon::Off);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
39 saveButton->setIcon(icon1);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
40
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
42 buttonBox->setObjectName(QString::fromUtf8("buttonBox"));
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
43 buttonBox->setOrientation(Qt::Vertical);
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
44 buttonBox->setStandardButtons(QDialogButtonBox::Ok);
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
45 buttonBox->addButton(saveButton,QDialogButtonBox::ActionRole);
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
46
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
47 temperature = new QSplineSeries();
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
48 pressure = new QSplineSeries();
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
49
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50 query.prepare("SELECT * FROM log_co2pressure WHERE code=:code ORDER BY datetime");
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 query.bindValue(":code", code);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 query.exec();
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 while (query.next()) {
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 timestamp = query.value("datetime").toDateTime().toSecsSinceEpoch() * 1000;
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 temperature->append(timestamp, query.value("temperature").toDouble());
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 pressure->append(timestamp, query.value("pressure").toDouble());
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 }
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 temperature->setName(tr("Temperature °C"));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60 temperature->setColor(QColorConstants::Svg::red);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
61 pressure->setName(tr("Pressure bar"));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 QPen pen(QColorConstants::Svg::navy);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 pen.setWidth(3);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 pressure->setPen(pen);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
66 chart = new QChart();
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 chart->setTitle(QString("%1 \"%2\"").arg(code).arg(name));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 chart->addSeries(temperature);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69 chart->addSeries(pressure);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
70
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 QDateTimeAxis *axisX = new QDateTimeAxis;
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 axisX->setTickCount(10);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 axisX->setFormat("dd MMM");
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 axisX->setTitleText(tr("Date"));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75 axisX->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 chart->addAxis(axisX, Qt::AlignBottom);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 temperature->attachAxis(axisX);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 pressure->attachAxis(axisX);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 QValueAxis *axisYT = new QValueAxis;
335
c4b4a2879bb8 The carbonation chart has fixed Y ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
81 axisYT->setRange(14.0, 25.0);
c4b4a2879bb8 The carbonation chart has fixed Y ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
82 axisYT->setTickCount(12);
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 axisYT->setLabelFormat("%.1f");
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 axisYT->setTitleText(tr("Temperature °C"));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85 axisYT->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 chart->addAxis(axisYT, Qt::AlignRight);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 temperature->attachAxis(axisYT);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 QValueAxis *axisYP = new QValueAxis;
335
c4b4a2879bb8 The carbonation chart has fixed Y ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
90 axisYP->setRange(0, 5.5);
c4b4a2879bb8 The carbonation chart has fixed Y ranges.
Michiel Broek <mbroek@mbse.eu>
parents: 332
diff changeset
91 axisYP->setTickCount(12);
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 axisYP->setLabelFormat("%.1f");
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93 axisYP->setTitleText(tr("Pressure bar"));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 axisYP->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 chart->addAxis(axisYP, Qt::AlignLeft);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 pressure->attachAxis(axisYP);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
98 chart->setAcceptHoverEvents(true);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
99
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
100 connect(temperature, &QSplineSeries::hovered, this, &ChartCarbonate::tooltip);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
101 connect(pressure, &QSplineSeries::hovered, this, &ChartCarbonate::tooltip);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
102
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
103 chartView = new QChartView(chart);
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 chartView->setRenderHint(QPainter::Antialiasing);
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
105 dialog->setLayout(new QHBoxLayout);
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 dialog->layout()->addWidget(chartView);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 dialog->layout()->addWidget(buttonBox);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109 QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
110 QObject::connect(buttonBox, SIGNAL(rejected()), dialog, SLOT(reject()));
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
111 QObject::connect(saveButton, SIGNAL(clicked()), this, SLOT(savePNG()));
332
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
112
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
113 dialog->setModal(true);
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
114 dialog->exec();
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 }
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
116
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 ChartCarbonate::~ChartCarbonate() {}
146874d7bb47 Added carbonation chart to it's own function. Added this chart to DetailCO2meter too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119
371
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
120
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
121 void ChartCarbonate::savePNG()
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
122 {
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
123 QString path = QFileDialog::getSaveFileName(this, tr("Save Image"), QDir::homePath() + "/carbonation.png", tr("Image (*.png)"));
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
124 if (path.isEmpty()) {
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
125 QMessageBox::warning(this, tr("Save File"), tr("No image file selected."));
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
126 return;
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
127 }
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
128
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
129 QImage img((chartView->size()), QImage::Format_ARGB32);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
130 QPainter painter;
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
131 painter.begin(&img);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
132 chartView->render(&painter);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
133 painter.setRenderHint(QPainter::Antialiasing);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
134 painter.end();
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
135 img.save(path);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
136 }
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
137
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
138
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
139 void ChartCarbonate::tooltip(QPointF point, bool state)
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
140 {
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
141 QAbstractSeries *series = qobject_cast<QAbstractSeries *>(sender());
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
142
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
143 if (t_tooltip == 0)
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
144 t_tooltip = new Callout(chart, series);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
145
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
146 if (state) {
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
147 QDateTime timeis = QDateTime::fromMSecsSinceEpoch(point.x());
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
148 QString suffix = (series == temperature) ? "°C":" bar";
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
149 t_tooltip->setSeries(series);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
150 t_tooltip->setText(QString("%1\n%2%3").arg(timeis.toString("dd-MM-yyyy hh:mm")).arg(point.y(), 2, 'f', 1).arg(suffix));
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
151 t_tooltip->setAnchor(point);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
152 t_tooltip->setZValue(11);
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
153 t_tooltip->updateGeometry();
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
154 t_tooltip->show();
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
155 } else {
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
156 t_tooltip->hide();
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
157 }
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
158 }
d03a426e0b6b On the fermenter, iSpindel, carbonation and brewday chart a tooltip with values is shown wheren hovering over the most important data lines. Changed the vertical to horzontal screen layout and added a save button to save the graph as .png image.
Michiel Broek <mbroek@mbse.eu>
parents: 335
diff changeset
159

mercurial