src/ChartiSpindel.cpp

Thu, 18 Aug 2022 20:34:15 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 18 Aug 2022 20:34:15 +0200
changeset 401
583148eb6e01
parent 372
d9c78eb19728
child 434
ebf4996ab396
permissions
-rw-r--r--

Init est_carb field for new products.

333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
1 /**
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
2 * ChartiSpindel.cpp is part of bmsapp.
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
3 *
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
4 * bmsapp is free software: you can redistribute it and/or modify
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
6 * the Free Software Foundation, either version 3 of the License, or
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
7 * (at your option) any later version.
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
8 *
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
9 * bmsapp is distributed in the hope that it will be useful,
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
12 * GNU General Public License for more details.
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
13 *
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
16 */
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
17 #include "ChartiSpindel.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: 334
diff changeset
18 #include "callout.h"
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
19 #include "MainWindow.h"
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
20
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
21
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
22 ChartiSpindel::ChartiSpindel(QString code, QString name, QWidget *parent) : QDialog(parent)
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
23 {
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
24 QSqlQuery query;
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
25 double timestamp;
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
26
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
27 qDebug() << "ChartiSpindel:" << code << name;
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
28
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
29 QDialog* dialog = new QDialog(parent);
334
9203fa01ddbf Version 0.2.15 with updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 333
diff changeset
30 dialog->setWindowTitle(tr("BMSapp - iSpindel ") + "\"" + name + "\"");
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
31 dialog->setObjectName(QString::fromUtf8("ChartiSpindel"));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
32 dialog->setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
33 dialog->resize(1024, 600);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel 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: 334
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: 334
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: 334
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: 334
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: 334
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: 334
diff changeset
40
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
41 QDialogButtonBox *buttonBox = new QDialogButtonBox(dialog);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel 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: 334
diff changeset
43 buttonBox->setOrientation(Qt::Vertical);
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel 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: 334
diff changeset
45 buttonBox->addButton(saveButton,QDialogButtonBox::ActionRole);
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel 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: 334
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: 334
diff changeset
48 density = 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: 334
diff changeset
49 battery = new QSplineSeries();
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
50
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
51 query.prepare("SELECT * FROM log_ispindel WHERE code=:code ORDER BY datetime");
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
52 query.bindValue(":code", code);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
53 query.exec();
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
54 while (query.next()) {
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
55 timestamp = query.value("datetime").toDateTime().toSecsSinceEpoch() * 1000;
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
56 temperature->append(timestamp, query.value("temperature").toDouble());
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
57 density->append(timestamp, query.value("sg").toDouble());
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
58 battery ->append(timestamp, query.value("battery").toDouble());
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
59 }
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
60
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: 334
diff changeset
61 temperature->setName(tr("Temperature"));
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
62 temperature->setColor(QColorConstants::Svg::red);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
63 density->setName(tr("SG"));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
64 QPen pen(QColorConstants::Svg::navy);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
65 pen.setWidth(3);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
66 density->setPen(pen);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
67 battery->setName(tr("Battery"));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
68 battery->setColor(QColorConstants::Svg::limegreen);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
69
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: 334
diff changeset
70 chart = new QChart();
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
71 chart->setTitle(QString("%1 \"%2\"").arg(code).arg(name));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
72 chart->addSeries(battery);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
73 chart->addSeries(temperature);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
74 chart->addSeries(density);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
75
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
76 QDateTimeAxis *axisX = new QDateTimeAxis;
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
77 axisX->setTickCount(10);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
78 axisX->setFormat("dd MMM");
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
79 axisX->setTitleText(tr("Date"));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
80 axisX->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
81 chart->addAxis(axisX, Qt::AlignBottom);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
82 battery->attachAxis(axisX);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
83 temperature->attachAxis(axisX);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
84 density->attachAxis(axisX);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
85
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
86 QValueAxis *axisYT = new QValueAxis;
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
87 axisYT->setTickCount(10);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
88 axisYT->setLabelFormat("%.1f");
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
89 axisYT->setTitleText(tr("Temperature °C"));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
90 axisYT->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
91 chart->addAxis(axisYT, Qt::AlignRight);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
92 temperature->attachAxis(axisYT);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
93
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
94 QValueAxis *axisYD = new QValueAxis;
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
95 axisYD->setTickCount(10);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
96 axisYD->setLabelFormat("%.3f");
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
97 axisYD->setTitleText("SG");
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
98 axisYD->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
99 chart->addAxis(axisYD, Qt::AlignLeft);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
100 density->attachAxis(axisYD);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
101
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
102 QValueAxis *axisYB = new QValueAxis;
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
103 axisYB->setTickCount(10);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
104 axisYB->setLabelFormat("%.2f");
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
105 axisYB->setTitleText(tr("Battery volt"));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
106 axisYB->setLabelsFont(QFont("Helvetica", 8, QFont::Normal));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
107 chart->addAxis(axisYB, Qt::AlignRight);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
108 battery->attachAxis(axisYB);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
109
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: 334
diff changeset
110 connect(temperature, &QSplineSeries::hovered, this, &ChartiSpindel::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: 334
diff changeset
111 connect(density, &QSplineSeries::hovered, this, &ChartiSpindel::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: 334
diff changeset
112 connect(battery, &QSplineSeries::hovered, this, &ChartiSpindel::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: 334
diff changeset
113
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: 334
diff changeset
114 chartView = new QChartView(chart);
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
115 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: 334
diff changeset
116 dialog->setLayout(new QHBoxLayout);
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
117 dialog->layout()->addWidget(chartView);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
118 dialog->layout()->addWidget(buttonBox);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
119
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
120 QObject::connect(buttonBox, SIGNAL(accepted()), dialog, SLOT(accept()));
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
121 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: 334
diff changeset
122 QObject::connect(saveButton, SIGNAL(clicked()), this, SLOT(savePNG()));
333
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
123
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
124 dialog->setModal(true);
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
125 dialog->exec();
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
126 }
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
127
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
128
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
129 ChartiSpindel::~ChartiSpindel() {}
499c95108bbd Moved Fermenter and iSpindel charts to their own functions. Added these to DetailFermenter and DetailiSpindel too.
Michiel Broek <mbroek@mbse.eu>
parents:
diff changeset
130
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: 334
diff changeset
131
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: 334
diff changeset
132 void ChartiSpindel::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: 334
diff changeset
133 {
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: 334
diff changeset
134 QString path = QFileDialog::getSaveFileName(this, tr("Save Image"), QDir::homePath() + "/ispindel.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: 334
diff changeset
135 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: 334
diff changeset
136 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: 334
diff changeset
137 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: 334
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: 334
diff changeset
139
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: 334
diff changeset
140 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: 334
diff changeset
141 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: 334
diff changeset
142 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: 334
diff changeset
143 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: 334
diff changeset
144 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: 334
diff changeset
145 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: 334
diff changeset
146 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: 334
diff changeset
147 }
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: 334
diff changeset
148
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: 334
diff changeset
149
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: 334
diff changeset
150 void ChartiSpindel::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: 334
diff changeset
151 {
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: 334
diff changeset
152 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: 334
diff changeset
153
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: 334
diff changeset
154 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: 334
diff changeset
155 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: 334
diff changeset
156
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: 334
diff changeset
157 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: 334
diff changeset
158 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: 334
diff changeset
159 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: 334
diff changeset
160 if (series == temperature)
372
d9c78eb19728 Version 0.2.21. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 371
diff changeset
161 t_tooltip->setText(QString(tr("%1\nTemperature %2°C")).arg(timeis.toString("dd-MM-yyyy hh:mm")).arg(point.y(), 2, 'f', 1));
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: 334
diff changeset
162 else if (series == density)
372
d9c78eb19728 Version 0.2.21. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 371
diff changeset
163 t_tooltip->setText(QString(tr("%1\nDensity %2 SG")).arg(timeis.toString("dd-MM-yyyy hh:mm")).arg(point.y(), 5, 'f', 4));
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: 334
diff changeset
164 else if (series == battery)
372
d9c78eb19728 Version 0.2.21. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 371
diff changeset
165 t_tooltip->setText(QString(tr("%1\nBattery %2 volt")).arg(timeis.toString("dd-MM-yyyy hh:mm")).arg(point.y(), 3, 'f', 2));
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: 334
diff changeset
166 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: 334
diff changeset
167 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: 334
diff changeset
168 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: 334
diff changeset
169 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: 334
diff changeset
170 } 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: 334
diff changeset
171 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: 334
diff changeset
172 }
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: 334
diff changeset
173 }
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: 334
diff changeset
174

mercurial