src/ChartiSpindel.cpp

Sun, 12 Feb 2023 13:58:36 +0100

author
Michiel Broek <mbroek@mbse.eu>
date
Sun, 12 Feb 2023 13:58:36 +0100
changeset 494
49ac23d25f61
parent 438
e06b04ef1579
child 498
c6f957fa7442
permissions
-rw-r--r--

In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.

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;
494
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
26 double sg_min = 1.2, sg_max = 0.8, sg;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
27 double temp_min = 100, temp_max = 0, temp;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
28 double batt_min = 4.5, batt_max = 3.0, batt;
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
29
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
30 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
31
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 QDialog* dialog = new QDialog(parent);
334
9203fa01ddbf Version 0.2.15 with updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 333
diff changeset
33 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
34 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
35 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
36 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
37
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
38 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
39 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
40 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
41 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
42 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
43
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 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
45 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
46 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
47 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
48 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
49
438
e06b04ef1579 Small changes to the iSpindel graph. Translated the dutch product edit window title.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
50 temperature = new QLineSeries();
e06b04ef1579 Small changes to the iSpindel graph. Translated the dutch product edit window title.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
51 density = new QLineSeries();
e06b04ef1579 Small changes to the iSpindel graph. Translated the dutch product edit window title.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
52 battery = new QLineSeries();
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
53
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 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
55 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
56 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
57 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
58 timestamp = query.value("datetime").toDateTime().toSecsSinceEpoch() * 1000;
494
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
59
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
60 sg = query.value("sg").toDouble();
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
61 if ((ceil(sg * 100) / 100) > sg_max)
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
62 sg_max = ceil(sg * 100) / 100;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
63 if ((floor(sg * 100) / 100) < sg_min)
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
64 sg_min = floor(sg * 100) / 100;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
65
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
66 temp = query.value("temperature").toDouble();
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
67 if (ceil(temp) > temp_max)
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
68 temp_max = ceil(temp);
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
69 if (floor(temp) < temp_min)
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
70 temp_min = floor(temp);
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
71
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
72 batt = round(query.value("battery").toDouble() * 500) / 500;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
73 if ((ceil(batt * 10) / 10) > batt_max)
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
74 batt_max = ceil(batt * 10) / 10;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
75 if ((floor(batt * 10) / 10) < batt_min)
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
76 batt_min = floor(batt * 10) / 10;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
77
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
78 temperature->append(timestamp, temp);
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
79 density->append(timestamp, sg);
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
80 battery ->append(timestamp, batt);
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
81 }
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
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
83 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
84 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
85 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
86 QPen pen(QColorConstants::Svg::navy);
434
ebf4996ab396 Charts downsize the pen from 3 to 2. Some nicer looking graphs.
Michiel Broek <mbroek@mbse.eu>
parents: 372
diff changeset
87 pen.setWidth(2);
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
88 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
89 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
90 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
91
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
92 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
93 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
94 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
95 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
96 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
97
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 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
99 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
100 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
101 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
102 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
103 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
104 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
105 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
106 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
107
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 QValueAxis *axisYT = new QValueAxis;
494
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
109 axisYT->setRange(temp_min, temp_max);
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
110 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
111 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
112 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
113 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
114 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
115 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
116
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 QValueAxis *axisYD = new QValueAxis;
494
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
118 axisYD->setRange(sg_min, sg_max);
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
119 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
120 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
121 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
122 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
123 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
124 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
125
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 QValueAxis *axisYB = new QValueAxis;
494
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
127 axisYB->setRange(batt_min, batt_max);
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
128 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
129 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
130 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
131 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
132 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
133 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
134
438
e06b04ef1579 Small changes to the iSpindel graph. Translated the dutch product edit window title.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
135 connect(temperature, &QLineSeries::hovered, this, &ChartiSpindel::tooltip);
e06b04ef1579 Small changes to the iSpindel graph. Translated the dutch product edit window title.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
136 connect(density, &QLineSeries::hovered, this, &ChartiSpindel::tooltip);
e06b04ef1579 Small changes to the iSpindel graph. Translated the dutch product edit window title.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
137 connect(battery, &QLineSeries::hovered, this, &ChartiSpindel::tooltip);
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
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 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
140 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
141 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
142 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
143 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
144
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
145 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
146 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
147 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
148
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
149 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
150 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
151 }
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
152
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
153
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
154 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
155
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
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 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
158 {
494
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
159 QSettings settings(QSettings::IniFormat, QSettings::UserScope, "mbse", "bmsapp");
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
160 QString dirName;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
161
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
162 /*
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
163 * First check if the directory stored in the settings file exists.
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
164 * It might be on a removable media that was last used ...
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
165 * If so, fallback to the user's home directory.
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
166 */
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
167 dirName = settings.value("paths/download").toString();
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
168 if (! QDir(dirName).exists()) {
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
169 dirName = QDir::homePath();
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
170 }
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
171
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
172 QString path = QFileDialog::getSaveFileName(this, tr("Save Image"), dirName + "/ispindel.png", tr("Image (*.png)"));
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
173 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
174 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
175 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
176 }
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
177
494
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
178 /*
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
179 * Update to current selected path
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
180 */
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
181 settings.setValue("paths/download", QFileInfo(path).absolutePath());
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
182
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
183 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
184 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
185 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
186 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
187 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
188 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
189 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
190 }
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
191
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
192
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
193 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
194 {
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
195 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
196
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
197 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
198 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
199
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
200 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
201 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
202 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
203 if (series == temperature)
372
d9c78eb19728 Version 0.2.21. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 371
diff changeset
204 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
205 else if (series == density)
372
d9c78eb19728 Version 0.2.21. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 371
diff changeset
206 t_tooltip->setText(QString(tr("%1\nDensity %2 SG")).arg(timeis.toString("dd-MM-yyyy hh:mm")).arg(point.y(), 5, 'f', 4));
494
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
207 else if (series == battery) {
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
208 double batt = point.y() - 3.064; /* 0% */
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
209 if (batt < 0)
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
210 batt = 0;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
211 batt = round(batt / 1.17875 * 1000.0) / 10; /* 100% range */
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
212 if (batt > 100)
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
213 batt = 100;
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
214 t_tooltip->setText(QString(tr("%1\nBattery %2 volt\nCapacity %3%")).arg(timeis.toString("dd-MM-yyyy hh:mm"))
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
215 .arg(point.y(), 3, 'f', 2).arg(batt, 2, 'f', 1, '0'));
49ac23d25f61 In monitor iSpindel: in the chart calculate the ranges, do't let the toolkit do that. Save the path for chart image download in the user settings. In the tooltip for the battery voltage line, also show the remaining battery capacity. In the monitor window show the battery capacity digit instead of allways 0. Updated the translations.
Michiel Broek <mbroek@mbse.eu>
parents: 438
diff changeset
216 }
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
217 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
218 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
219 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
220 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
221 } 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
222 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
223 }
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
224 }
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
225

mercurial