src/ChartiSpindel.cpp

Sat, 19 Aug 2023 16:58:03 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 19 Aug 2023 16:58:03 +0200
changeset 498
c6f957fa7442
parent 494
49ac23d25f61
child 501
a01ae5ff0e96
permissions
-rw-r--r--

In fermentation plot draw the SG line with temperature compensation.

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"
498
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
20 #include "Utils.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
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
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 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
24 {
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 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
26 double timestamp;
498
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
27 double sg_min = 1.2, sg_max = 0.8, mg, sg;
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
28 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
29 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
30
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 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
32
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 QDialog* dialog = new QDialog(parent);
334
9203fa01ddbf Version 0.2.15 with updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 333
diff changeset
34 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
35 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
36 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
37 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
38
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
39 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
40 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
41 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
42 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
43 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
44
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
45 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
46 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
47 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
48 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
49 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
50
438
e06b04ef1579 Small changes to the iSpindel graph. Translated the dutch product edit window title.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
51 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
52 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
53 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
54
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.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
56 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
57 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
58 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
59 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
60
498
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
61 mg = query.value("sg").toDouble();
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
62 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
63 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
64 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
65 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
66 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
67
498
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
68 /*
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
69 * Correct the SG plotline for temperature.
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
70 */
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
71 sg = Utils::HydroCorrection(mg, temp, 20.0);
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
72 if ((ceil(sg * 100) / 100) > sg_max)
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
73 sg_max = ceil(sg * 100) / 100;
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
74 if ((floor(sg * 100) / 100) < sg_min)
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
75 sg_min = floor(sg * 100) / 100;
c6f957fa7442 In fermentation plot draw the SG line with temperature compensation.
Michiel Broek <mbroek@mbse.eu>
parents: 494
diff changeset
76
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
77 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
78 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
79 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
80 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
81 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
82
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
83 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
84 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
85 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
86 }
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
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
88 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
89 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
90 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
91 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
92 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
93 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
94 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
95 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
96
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
97 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
98 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
99 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
100 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
101 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
102
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 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
104 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
105 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
106 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
107 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
108 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
109 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
110 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
111 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
112
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 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
114 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
115 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
116 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
117 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
118 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
119 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
120 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
121
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 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
123 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
124 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
125 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
126 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
127 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
128 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
129 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
130
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 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
132 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
133 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
134 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
135 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
136 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
137 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
138 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
139
438
e06b04ef1579 Small changes to the iSpindel graph. Translated the dutch product edit window title.
Michiel Broek <mbroek@mbse.eu>
parents: 434
diff changeset
140 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
141 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
142 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
143
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 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
145 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
146 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
147 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
148 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
149
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 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
151 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
152 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
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 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
155 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
156 }
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
157
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
158
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
159 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
160
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
161
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 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
163 {
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
164 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
165 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
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 /*
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 * 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
169 * 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
170 * 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
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 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
173 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
174 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
175 }
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
176
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
177 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
178 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
179 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
180 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
181 }
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
182
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
183 /*
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
184 * 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
185 */
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
186 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
187
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
188 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
189 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
190 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
191 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
192 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
193 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
194 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
195 }
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
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 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
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 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
201
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 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
203 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
204
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 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
206 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
207 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
208 if (series == temperature)
372
d9c78eb19728 Version 0.2.21. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 371
diff changeset
209 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
210 else if (series == density)
372
d9c78eb19728 Version 0.2.21. Updated translations.
Michiel Broek <mbroek@mbse.eu>
parents: 371
diff changeset
211 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
212 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
213 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
214 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
215 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
216 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
217 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
218 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
219 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
220 .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
221 }
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
222 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
223 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
224 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
225 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
226 } 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
227 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
228 }
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
229 }
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
230

mercurial