summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-19 22:28:16 +0000
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-11-19 22:28:16 +0000
commit21658383e5c188b588aecab46e827cb90a88bc26 (patch)
tree92030ebb3cec9020c271fc417e5844b26ceed37a /qt-ui
parent76c44dd6a30065e8d6aa9427aaae14f10cebb4a5 (diff)
downloadsubsurface-21658383e5c188b588aecab46e827cb90a88bc26.tar.gz
Profile: keep the plotInfo in the corresponding member variable
We had the variable. As a pointer. Which we used memset to clear. Ouch - that smells like some bad cut and paste. With this change the object keeps the corresponding plotInfo around (just like some others do) and can use it later. I suspect this code could use some larger cleanup, but it's a bit too late for this in the development cycle, I guess. I'm sure I'll regret this in the future... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/profile/profilewidget2.cpp36
-rw-r--r--qt-ui/profile/profilewidget2.h3
2 files changed, 20 insertions, 19 deletions
diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp
index d49c9525c..14ae7ca5b 100644
--- a/qt-ui/profile/profilewidget2.cpp
+++ b/qt-ui/profile/profilewidget2.cpp
@@ -491,16 +491,16 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
* so I'll *not* calculate everything if something is not being
* shown.
*/
- struct plot_info pInfo = calculate_max_limits_new(&displayed_dive, currentdc);
- create_plot_info_new(&displayed_dive, currentdc, &pInfo);
+ plotInfo = calculate_max_limits_new(&displayed_dive, currentdc);
+ create_plot_info_new(&displayed_dive, currentdc, &plotInfo);
if(shouldCalculateMaxTime)
- maxtime = get_maxtime(&pInfo);
+ maxtime = get_maxtime(&plotInfo);
/* Only update the max depth if it's bigger than the current ones
* when we are dragging the handler to plan / add dive.
* otherwhise, update normally.
*/
- int newMaxDepth = get_maxdepth(&pInfo);
+ int newMaxDepth = get_maxdepth(&plotInfo);
if(!shouldCalculateMaxDepth) {
if (maxdepth < newMaxDepth) {
maxdepth = newMaxDepth;
@@ -509,23 +509,23 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
maxdepth = newMaxDepth;
}
- dataModel->setDive(&displayed_dive, pInfo);
- toolTipItem->setPlotInfo(pInfo);
+ dataModel->setDive(&displayed_dive, plotInfo);
+ toolTipItem->setPlotInfo(plotInfo);
// It seems that I'll have a lot of boilerplate setting the model / axis for
// each item, I'll mostly like to fix this in the future, but I'll keep at this for now.
profileYAxis->setMaximum(maxdepth);
profileYAxis->updateTicks();
- temperatureAxis->setMinimum(pInfo.mintemp);
- temperatureAxis->setMaximum(pInfo.maxtemp);
+ temperatureAxis->setMinimum(plotInfo.mintemp);
+ temperatureAxis->setMaximum(plotInfo.maxtemp);
- if (pInfo.maxhr) {
- heartBeatAxis->setMinimum(pInfo.minhr);
- heartBeatAxis->setMaximum(pInfo.maxhr);
+ if (plotInfo.maxhr) {
+ heartBeatAxis->setMinimum(plotInfo.minhr);
+ heartBeatAxis->setMaximum(plotInfo.maxhr);
heartBeatAxis->updateTicks(HR_AXIS); // this shows the ticks
}
- heartBeatAxis->setVisible(prefs.hrgraph && pInfo.maxhr);
+ heartBeatAxis->setVisible(prefs.hrgraph && plotInfo.maxhr);
percentageAxis->setMinimum(0);
percentageAxis->setMaximum(100);
@@ -550,15 +550,15 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
incr *= 2;
timeAxis->setTickInterval(incr);
timeAxis->updateTicks();
- cylinderPressureAxis->setMinimum(pInfo.minpressure);
- cylinderPressureAxis->setMaximum(pInfo.maxpressure);
+ cylinderPressureAxis->setMinimum(plotInfo.minpressure);
+ cylinderPressureAxis->setMaximum(plotInfo.maxpressure);
- rulerItem->setPlotInfo(pInfo);
- tankItem->setData(dataModel, &pInfo, &displayed_dive);
+ rulerItem->setPlotInfo(plotInfo);
+ tankItem->setData(dataModel, &plotInfo, &displayed_dive);
meanDepth->setVisible(prefs.show_average_depth);
- meanDepth->setMeanDepth(pInfo.meandepth);
+ meanDepth->setMeanDepth(plotInfo.meandepth);
meanDepth->setLine(0, 0, timeAxis->posAtValue(currentdc->duration.seconds), 0);
- Animations::moveTo(meanDepth,3, profileYAxis->posAtValue(pInfo.meandepth));
+ Animations::moveTo(meanDepth,3, profileYAxis->posAtValue(plotInfo.meandepth));
dataModel->emitDataChanged();
// The event items are a bit special since we don't know how many events are going to
diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h
index 79d5938c1..477ddf4a7 100644
--- a/qt-ui/profile/profilewidget2.h
+++ b/qt-ui/profile/profilewidget2.h
@@ -16,6 +16,7 @@
#include "graphicsview-common.h"
#include "divelineitem.h"
#include "diveprofileitem.h"
+#include "display.h"
class RulerItem2;
struct dive;
@@ -145,7 +146,7 @@ private:
// All those here should probably be merged into one structure,
// So it's esyer to replicate for more dives later.
// In the meantime, keep it here.
- struct plot_info *plotInfo;
+ struct plot_info plotInfo;
DepthAxis *profileYAxis;
PartialGasPressureAxis *gasYAxis;
TemperatureAxis *temperatureAxis;