mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
profile: attempt to port mobile-visibility code
There was a bunch of conditionally compiled code on mobile that had special hiding/unhiding rules. Try to unify that with the desktop code by introducing a "simplified" flag. This certainly breaks and will have to be finetuned. In particular, I can't test CCR dives, which are treated specially on mobile. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
1a429d9b17
commit
5c83fcd647
2 changed files with 65 additions and 76 deletions
|
@ -138,40 +138,60 @@ void ProfileScene::clear()
|
||||||
eventItems.clear();
|
eventItems.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool ppGraphsEnabled()
|
static bool ppGraphsEnabled(const struct divecomputer *dc, bool simplified)
|
||||||
{
|
{
|
||||||
return prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe;
|
return simplified ? (dc->divemode == CCR && prefs.pp_graphs.po2)
|
||||||
|
: (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update visibility of non-interactive chart features according to preferences
|
// Update visibility of non-interactive chart features according to preferences
|
||||||
void ProfileScene::updateVisibility(bool diveHasHeartBeat)
|
void ProfileScene::updateVisibility(bool diveHasHeartBeat, bool simplified)
|
||||||
{
|
{
|
||||||
#ifndef SUBSURFACE_MOBILE
|
const struct divecomputer *currentdc = get_dive_dc_const(d, dc);
|
||||||
|
if (!currentdc)
|
||||||
|
return;
|
||||||
|
bool ppGraphs = ppGraphsEnabled(currentdc, simplified);
|
||||||
|
|
||||||
|
if (simplified) {
|
||||||
|
pn2GasItem->setVisible(false);
|
||||||
|
po2GasItem->setVisible(ppGraphs);
|
||||||
|
pheGasItem->setVisible(false);
|
||||||
|
|
||||||
|
temperatureItem->setVisible(!ppGraphs);
|
||||||
|
tankItem->setVisible(!ppGraphs && prefs.tankbar);
|
||||||
|
|
||||||
|
o2SetpointGasItem->setVisible(ppGraphs && prefs.show_ccr_setpoint);
|
||||||
|
ccrsensor1GasItem->setVisible(ppGraphs && prefs.show_ccr_sensors);
|
||||||
|
ccrsensor2GasItem->setVisible(ppGraphs && prefs.show_ccr_sensors && (currentdc->no_o2sensors > 1));
|
||||||
|
ccrsensor3GasItem->setVisible(ppGraphs && prefs.show_ccr_sensors && (currentdc->no_o2sensors > 1));
|
||||||
|
ocpo2GasItem->setVisible((currentdc->divemode == PSCR) && prefs.show_scr_ocpo2);
|
||||||
|
} else {
|
||||||
pn2GasItem->setVisible(prefs.pp_graphs.pn2);
|
pn2GasItem->setVisible(prefs.pp_graphs.pn2);
|
||||||
po2GasItem->setVisible(prefs.pp_graphs.po2);
|
po2GasItem->setVisible(prefs.pp_graphs.po2);
|
||||||
pheGasItem->setVisible(prefs.pp_graphs.phe);
|
pheGasItem->setVisible(prefs.pp_graphs.phe);
|
||||||
|
|
||||||
const struct divecomputer *currentdc = d ? get_dive_dc_const(d, dc) : nullptr;
|
bool setpointflag = currentdc->divemode == CCR && prefs.pp_graphs.po2;
|
||||||
bool setpointflag = currentdc && currentdc->divemode == CCR && prefs.pp_graphs.po2;
|
|
||||||
bool sensorflag = setpointflag && prefs.show_ccr_sensors;
|
bool sensorflag = setpointflag && prefs.show_ccr_sensors;
|
||||||
o2SetpointGasItem->setVisible(setpointflag && prefs.show_ccr_setpoint);
|
o2SetpointGasItem->setVisible(setpointflag && prefs.show_ccr_setpoint);
|
||||||
ccrsensor1GasItem->setVisible(sensorflag);
|
ccrsensor1GasItem->setVisible(sensorflag);
|
||||||
ccrsensor2GasItem->setVisible(currentdc && sensorflag && currentdc->no_o2sensors > 1);
|
ccrsensor2GasItem->setVisible(sensorflag && currentdc->no_o2sensors > 1);
|
||||||
ccrsensor3GasItem->setVisible(currentdc && sensorflag && currentdc->no_o2sensors > 2);
|
ccrsensor3GasItem->setVisible(sensorflag && currentdc->no_o2sensors > 2);
|
||||||
ocpo2GasItem->setVisible(currentdc && currentdc->divemode == PSCR && prefs.show_scr_ocpo2);
|
ocpo2GasItem->setVisible(currentdc->divemode == PSCR && prefs.show_scr_ocpo2);
|
||||||
|
|
||||||
heartBeatItem->setVisible(prefs.hrgraph && diveHasHeartBeat);
|
heartBeatItem->setVisible(prefs.hrgraph && diveHasHeartBeat);
|
||||||
#endif
|
|
||||||
diveCeiling->setVisible(prefs.calcceiling);
|
diveCeiling->setVisible(prefs.calcceiling);
|
||||||
decoModelParameters->setVisible(prefs.decoinfo);
|
decoModelParameters->setVisible(prefs.decoinfo);
|
||||||
#ifndef SUBSURFACE_MOBILE
|
|
||||||
for (DiveCalculatedTissue *tissue: allTissues)
|
for (DiveCalculatedTissue *tissue: allTissues)
|
||||||
tissue->setVisible(prefs.calcalltissues && prefs.calcceiling);
|
tissue->setVisible(prefs.calcalltissues && prefs.calcceiling);
|
||||||
percentageItem->setVisible(prefs.percentagegraph);
|
percentageItem->setVisible(prefs.percentagegraph);
|
||||||
#endif
|
|
||||||
meanDepthItem->setVisible(prefs.show_average_depth);
|
meanDepthItem->setVisible(prefs.show_average_depth);
|
||||||
reportedCeiling->setVisible(prefs.dcceiling);
|
reportedCeiling->setVisible(prefs.dcceiling);
|
||||||
tankItem->setVisible(prefs.tankbar);
|
tankItem->setVisible(prefs.tankbar);
|
||||||
|
temperatureItem->setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProfileScene::resize(QSizeF size)
|
void ProfileScene::resize(QSizeF size)
|
||||||
|
@ -199,15 +219,19 @@ struct VerticalAxisLayout {
|
||||||
bool visible;
|
bool visible;
|
||||||
};
|
};
|
||||||
|
|
||||||
void ProfileScene::updateAxes(bool diveHasHeartBeat)
|
void ProfileScene::updateAxes(bool diveHasHeartBeat, bool simplified)
|
||||||
{
|
{
|
||||||
|
const struct divecomputer *currentdc = get_dive_dc_const(d, dc);
|
||||||
|
if (!currentdc)
|
||||||
|
return;
|
||||||
|
|
||||||
// Calculate left and right border needed for the axes.
|
// Calculate left and right border needed for the axes.
|
||||||
// viz. the depth axis to the left and the partial pressure axis to the right.
|
// viz. the depth axis to the left and the partial pressure axis to the right.
|
||||||
// Thus, calculating the "border" of the graph is trivial.
|
// Thus, calculating the "border" of the graph is trivial.
|
||||||
double leftBorder = profileYAxis->width();
|
double leftBorder = profileYAxis->width();
|
||||||
if (prefs.hrgraph)
|
if (prefs.hrgraph)
|
||||||
leftBorder = std::max(leftBorder, heartBeatAxis->width());
|
leftBorder = std::max(leftBorder, heartBeatAxis->width());
|
||||||
double rightWidth = ppGraphsEnabled() ? gasYAxis->width() : 0.0;
|
double rightWidth = ppGraphsEnabled(current_dc, simplified) ? gasYAxis->width() : 0.0;
|
||||||
double rightBorder = sceneRect().width() - rightWidth;
|
double rightBorder = sceneRect().width() - rightWidth;
|
||||||
double width = rightBorder - leftBorder;
|
double width = rightBorder - leftBorder;
|
||||||
|
|
||||||
|
@ -246,7 +270,7 @@ void ProfileScene::updateAxes(bool diveHasHeartBeat)
|
||||||
// Note: axes are listed from bottom to top, since they are added that way.
|
// Note: axes are listed from bottom to top, since they are added that way.
|
||||||
{ heartBeatAxis, 75.0, prefs.hrgraph && diveHasHeartBeat },
|
{ heartBeatAxis, 75.0, prefs.hrgraph && diveHasHeartBeat },
|
||||||
{ percentageAxis, 50.0, prefs.percentagegraph },
|
{ percentageAxis, 50.0, prefs.percentagegraph },
|
||||||
{ gasYAxis, 75.0, ppGraphsEnabled() },
|
{ gasYAxis, 75.0, ppGraphsEnabled(currentdc, simplified) },
|
||||||
{ temperatureAxis, 50.0, true },
|
{ temperatureAxis, 50.0, true },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -328,14 +352,6 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
||||||
|
|
||||||
int animSpeed = instant || printMode ? 0 : qPrefDisplay::animation_speed();
|
int animSpeed = instant || printMode ? 0 : qPrefDisplay::animation_speed();
|
||||||
|
|
||||||
bool setpointflag = (currentdc->divemode == CCR) && prefs.pp_graphs.po2;
|
|
||||||
bool sensorflag = setpointflag && prefs.show_ccr_sensors;
|
|
||||||
o2SetpointGasItem->setVisible(setpointflag && prefs.show_ccr_setpoint);
|
|
||||||
ccrsensor1GasItem->setVisible(sensorflag);
|
|
||||||
ccrsensor2GasItem->setVisible(sensorflag && (currentdc->no_o2sensors > 1));
|
|
||||||
ccrsensor3GasItem->setVisible(sensorflag && (currentdc->no_o2sensors > 2));
|
|
||||||
ocpo2GasItem->setVisible((currentdc->divemode == PSCR) && prefs.show_scr_ocpo2);
|
|
||||||
|
|
||||||
// A non-null planner_ds signals to create_plot_info_new that the dive is currently planned.
|
// A non-null planner_ds signals to create_plot_info_new that the dive is currently planned.
|
||||||
struct deco_state *planner_ds = inPlanner && plannerModel ? &plannerModel->final_deco_state : nullptr;
|
struct deco_state *planner_ds = inPlanner && plannerModel ? &plannerModel->final_deco_state : nullptr;
|
||||||
|
|
||||||
|
@ -350,8 +366,14 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
||||||
create_plot_info_new(d, get_dive_dc_const(d, dc), &plotInfo, !calcMax, planner_ds);
|
create_plot_info_new(d, get_dive_dc_const(d, dc), &plotInfo, !calcMax, planner_ds);
|
||||||
|
|
||||||
bool hasHeartBeat = plotInfo.maxhr;
|
bool hasHeartBeat = plotInfo.maxhr;
|
||||||
updateVisibility(hasHeartBeat);
|
// For mobile we might want to turn of some features that are normally shown.
|
||||||
updateAxes(hasHeartBeat);
|
#ifdef SUBSURFACE_MOBILE
|
||||||
|
bool simplified = true;
|
||||||
|
#else
|
||||||
|
bool simplified = false;
|
||||||
|
#endif
|
||||||
|
updateVisibility(hasHeartBeat, simplified);
|
||||||
|
updateAxes(hasHeartBeat, simplified);
|
||||||
|
|
||||||
int newMaxtime = get_maxtime(&plotInfo);
|
int newMaxtime = get_maxtime(&plotInfo);
|
||||||
if (calcMax || newMaxtime > maxtime)
|
if (calcMax || newMaxtime > maxtime)
|
||||||
|
@ -414,42 +436,9 @@ void ProfileScene::plotDive(const struct dive *dIn, int dcIn, DivePlannerPointsM
|
||||||
timeAxis->updateTicks(animSpeed);
|
timeAxis->updateTicks(animSpeed);
|
||||||
cylinderPressureAxis->setBounds(plotInfo.minpressure, plotInfo.maxpressure);
|
cylinderPressureAxis->setBounds(plotInfo.minpressure, plotInfo.maxpressure);
|
||||||
|
|
||||||
#ifdef SUBSURFACE_MOBILE
|
|
||||||
if (currentdc->divemode == CCR) {
|
|
||||||
tankItem->setVisible(false);
|
|
||||||
pn2GasItem->setVisible(false);
|
|
||||||
po2GasItem->setVisible(prefs.pp_graphs.po2);
|
|
||||||
pheGasItem->setVisible(false);
|
|
||||||
o2SetpointGasItem->setVisible(prefs.show_ccr_setpoint);
|
|
||||||
ccrsensor1GasItem->setVisible(prefs.show_ccr_sensors);
|
|
||||||
ccrsensor2GasItem->setVisible(prefs.show_ccr_sensors && (currentdc->no_o2sensors > 1));
|
|
||||||
ccrsensor3GasItem->setVisible(prefs.show_ccr_sensors && (currentdc->no_o2sensors > 1));
|
|
||||||
ocpo2GasItem->setVisible((currentdc->divemode == PSCR) && prefs.show_scr_ocpo2);
|
|
||||||
//when no gas graph, we can show temperature
|
|
||||||
if (!po2GasItem->isVisible() &&
|
|
||||||
!o2SetpointGasItem->isVisible() &&
|
|
||||||
!ccrsensor1GasItem->isVisible() &&
|
|
||||||
!ccrsensor2GasItem->isVisible() &&
|
|
||||||
!ccrsensor3GasItem->isVisible() &&
|
|
||||||
!ocpo2GasItem->isVisible())
|
|
||||||
temperatureItem->setVisible(true);
|
|
||||||
else
|
|
||||||
temperatureItem->setVisible(false);
|
|
||||||
} else {
|
|
||||||
tankItem->setVisible(prefs.tankbar);
|
|
||||||
pn2GasItem->setVisible(false);
|
|
||||||
po2GasItem->setVisible(false);
|
|
||||||
pheGasItem->setVisible(false);
|
|
||||||
o2SetpointGasItem->setVisible(false);
|
|
||||||
ccrsensor1GasItem->setVisible(false);
|
|
||||||
ccrsensor2GasItem->setVisible(false);
|
|
||||||
ccrsensor3GasItem->setVisible(false);
|
|
||||||
ocpo2GasItem->setVisible(false);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
tankItem->setData(d, firstSecond, lastSecond);
|
tankItem->setData(d, firstSecond, lastSecond);
|
||||||
|
|
||||||
if (ppGraphsEnabled()) {
|
if (ppGraphsEnabled(current_dc, simplified)) {
|
||||||
double max = prefs.pp_graphs.phe ? dataModel->pheMax() : -1;
|
double max = prefs.pp_graphs.phe ? dataModel->pheMax() : -1;
|
||||||
if (prefs.pp_graphs.pn2)
|
if (prefs.pp_graphs.pn2)
|
||||||
max = std::max(dataModel->pn2Max(), max);
|
max = std::max(dataModel->pn2Max(), max);
|
||||||
|
|
|
@ -54,8 +54,8 @@ private:
|
||||||
template<typename T, class... Args> T *createItem(const DiveCartesianAxis &vAxis, int vColumn, int z, Args&&... args);
|
template<typename T, class... Args> T *createItem(const DiveCartesianAxis &vAxis, int vColumn, int z, Args&&... args);
|
||||||
PartialPressureGasItem *createPPGas(int column, color_index_t color, color_index_t colorAlert,
|
PartialPressureGasItem *createPPGas(int column, color_index_t color, color_index_t colorAlert,
|
||||||
const double *thresholdSettingsMin, const double *thresholdSettingsMax);
|
const double *thresholdSettingsMin, const double *thresholdSettingsMax);
|
||||||
void updateVisibility(bool diveHasHeartBeat); // Update visibility of non-interactive chart features according to preferences
|
void updateVisibility(bool diveHasHeartBeat, bool simplified); // Update visibility of non-interactive chart features according to preferences
|
||||||
void updateAxes(bool diveHasHeartBeat); // Update axes according to preferences
|
void updateAxes(bool diveHasHeartBeat, bool simplified); // Update axes according to preferences
|
||||||
|
|
||||||
friend class ProfileWidget2; // For now, give the ProfileWidget full access to the objects on the scene
|
friend class ProfileWidget2; // For now, give the ProfileWidget full access to the objects on the scene
|
||||||
double dpr; // Device Pixel Ratio. A DPR of one corresponds to a "standard" PC screen.
|
double dpr; // Device Pixel Ratio. A DPR of one corresponds to a "standard" PC screen.
|
||||||
|
|
Loading…
Add table
Reference in a new issue