Profile: don't compile code that isn't needed on mobile

We were creating a couple dozen objects that we never needed and because
of that triggered several dozen callbacks whenever the model data changed.
All for UI elements of the profile that are either not used in the mobile
app (like the calculated ceiling or the partial pressure / tissue
saturation graphs), or are only useful when using the profile
interactively (which we also don't do on mobile).

I don't know if this will make a significant impact on performance, but it
seems like the right thing to do either way.

A positive side effect is that the odd blue line on top of the rendered
profile is gone as well.

Fixes #1007

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2016-02-06 13:25:58 -08:00
parent d2928a137c
commit 17134be96d
2 changed files with 93 additions and 47 deletions

View file

@ -83,7 +83,9 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
zoomFactor(1.15), zoomFactor(1.15),
background(new DivePixmapItem()), background(new DivePixmapItem()),
backgroundFile(":poster"), backgroundFile(":poster"),
#ifndef SUBSURFACE_MOBILE
toolTipItem(new ToolTipItem()), toolTipItem(new ToolTipItem()),
#endif
isPlotZoomed(prefs.zoomed_plot),// no! bad use of prefs. 'PreferencesDialog::loadSettings' NOT CALLED yet. isPlotZoomed(prefs.zoomed_plot),// no! bad use of prefs. 'PreferencesDialog::loadSettings' NOT CALLED yet.
profileYAxis(new DepthAxis(this)), profileYAxis(new DepthAxis(this)),
gasYAxis(new PartialGasPressureAxis(this)), gasYAxis(new PartialGasPressureAxis(this)),
@ -95,9 +97,10 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
cylinderPressureAxis(new DiveCartesianAxis(this)), cylinderPressureAxis(new DiveCartesianAxis(this)),
gasPressureItem(new DiveGasPressureItem()), gasPressureItem(new DiveGasPressureItem()),
diveComputerText(new DiveTextItem()), diveComputerText(new DiveTextItem()),
reportedCeiling(new DiveReportedCeiling()),
#ifndef SUBSURFACE_MOBILE
diveCeiling(new DiveCalculatedCeiling(this)), diveCeiling(new DiveCalculatedCeiling(this)),
decoModelParameters(new DiveTextItem()), decoModelParameters(new DiveTextItem()),
reportedCeiling(new DiveReportedCeiling()),
pn2GasItem(new PartialPressureGasItem()), pn2GasItem(new PartialPressureGasItem()),
pheGasItem(new PartialPressureGasItem()), pheGasItem(new PartialPressureGasItem()),
po2GasItem(new PartialPressureGasItem()), po2GasItem(new PartialPressureGasItem()),
@ -113,6 +116,7 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
mouseFollowerVertical(new DiveLineItem()), mouseFollowerVertical(new DiveLineItem()),
mouseFollowerHorizontal(new DiveLineItem()), mouseFollowerHorizontal(new DiveLineItem()),
rulerItem(new RulerItem2()), rulerItem(new RulerItem2()),
#endif
tankItem(new TankItem()), tankItem(new TankItem()),
isGrayscale(false), isGrayscale(false),
printMode(false), printMode(false),
@ -162,7 +166,6 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
ProfileWidget2::~ProfileWidget2() ProfileWidget2::~ProfileWidget2()
{ {
delete background; delete background;
delete toolTipItem;
delete profileYAxis; delete profileYAxis;
delete gasYAxis; delete gasYAxis;
delete temperatureAxis; delete temperatureAxis;
@ -173,8 +176,10 @@ ProfileWidget2::~ProfileWidget2()
delete cylinderPressureAxis; delete cylinderPressureAxis;
delete gasPressureItem; delete gasPressureItem;
delete diveComputerText; delete diveComputerText;
delete diveCeiling;
delete reportedCeiling; delete reportedCeiling;
#ifndef SUBSURFACE_MOBILE
delete toolTipItem;
delete diveCeiling;
delete pn2GasItem; delete pn2GasItem;
delete pheGasItem; delete pheGasItem;
delete po2GasItem; delete po2GasItem;
@ -190,6 +195,7 @@ ProfileWidget2::~ProfileWidget2()
delete mouseFollowerVertical; delete mouseFollowerVertical;
delete mouseFollowerHorizontal; delete mouseFollowerHorizontal;
delete rulerItem; delete rulerItem;
#endif
delete tankItem; delete tankItem;
} }
@ -199,7 +205,6 @@ ProfileWidget2::~ProfileWidget2()
void ProfileWidget2::addItemsToScene() void ProfileWidget2::addItemsToScene()
{ {
scene()->addItem(background); scene()->addItem(background);
scene()->addItem(toolTipItem);
scene()->addItem(profileYAxis); scene()->addItem(profileYAxis);
scene()->addItem(gasYAxis); scene()->addItem(gasYAxis);
scene()->addItem(temperatureAxis); scene()->addItem(temperatureAxis);
@ -215,9 +220,11 @@ void ProfileWidget2::addItemsToScene()
// so instead this adds a special magic key/value pair to the object to mark it // so instead this adds a special magic key/value pair to the object to mark it
diveComputerText->setData(SUBSURFACE_OBJ_DATA, SUBSURFACE_OBJ_DC_TEXT); diveComputerText->setData(SUBSURFACE_OBJ_DATA, SUBSURFACE_OBJ_DC_TEXT);
scene()->addItem(diveComputerText); scene()->addItem(diveComputerText);
scene()->addItem(reportedCeiling);
#ifndef SUBSURFACE_MOBILE
scene()->addItem(toolTipItem);
scene()->addItem(diveCeiling); scene()->addItem(diveCeiling);
scene()->addItem(decoModelParameters); scene()->addItem(decoModelParameters);
scene()->addItem(reportedCeiling);
scene()->addItem(pn2GasItem); scene()->addItem(pn2GasItem);
scene()->addItem(pheGasItem); scene()->addItem(pheGasItem);
scene()->addItem(po2GasItem); scene()->addItem(po2GasItem);
@ -238,6 +245,7 @@ void ProfileWidget2::addItemsToScene()
pen.setWidth(0); pen.setWidth(0);
mouseFollowerHorizontal->setPen(pen); mouseFollowerHorizontal->setPen(pen);
mouseFollowerVertical->setPen(pen); mouseFollowerVertical->setPen(pen);
Q_FOREACH (DiveCalculatedTissue *tissue, allTissues) { Q_FOREACH (DiveCalculatedTissue *tissue, allTissues) {
scene()->addItem(tissue); scene()->addItem(tissue);
} }
@ -246,14 +254,17 @@ void ProfileWidget2::addItemsToScene()
} }
scene()->addItem(ambPressureItem); scene()->addItem(ambPressureItem);
scene()->addItem(gflineItem); scene()->addItem(gflineItem);
#endif
} }
void ProfileWidget2::setupItemOnScene() void ProfileWidget2::setupItemOnScene()
{ {
background->setZValue(9999); background->setZValue(9999);
#ifndef SUBSURFACE_MOBILE
toolTipItem->setZValue(9998); toolTipItem->setZValue(9998);
toolTipItem->setTimeAxis(timeAxis); toolTipItem->setTimeAxis(timeAxis);
rulerItem->setZValue(9997); rulerItem->setZValue(9997);
#endif
tankItem->setZValue(100); tankItem->setZValue(100);
profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom); profileYAxis->setOrientation(DiveCartesianAxis::TopToBottom);
@ -273,6 +284,7 @@ void ProfileWidget2::setupItemOnScene()
gasYAxis->setFontLabelScale(0.7); gasYAxis->setFontLabelScale(0.7);
gasYAxis->setLineSize(96); gasYAxis->setLineSize(96);
#ifndef SUBSURFACE_MOBILE
heartBeatAxis->setOrientation(DiveCartesianAxis::BottomToTop); heartBeatAxis->setOrientation(DiveCartesianAxis::BottomToTop);
heartBeatAxis->setTickSize(0.2); heartBeatAxis->setTickSize(0.2);
heartBeatAxis->setTickInterval(10); heartBeatAxis->setTickInterval(10);
@ -284,6 +296,7 @@ void ProfileWidget2::setupItemOnScene()
percentageAxis->setTickInterval(10); percentageAxis->setTickInterval(10);
percentageAxis->setFontLabelScale(0.7); percentageAxis->setFontLabelScale(0.7);
percentageAxis->setLineSize(96); percentageAxis->setLineSize(96);
#endif
temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop); temperatureAxis->setOrientation(DiveCartesianAxis::BottomToTop);
temperatureAxis->setTickSize(2); temperatureAxis->setTickSize(2);
@ -297,16 +310,16 @@ void ProfileWidget2::setupItemOnScene()
diveComputerText->setAlignment(Qt::AlignRight | Qt::AlignTop); diveComputerText->setAlignment(Qt::AlignRight | Qt::AlignTop);
diveComputerText->setBrush(getColor(TIME_TEXT, isGrayscale)); diveComputerText->setBrush(getColor(TIME_TEXT, isGrayscale));
rulerItem->setAxis(timeAxis, profileYAxis);
tankItem->setHorizontalAxis(timeAxis); tankItem->setHorizontalAxis(timeAxis);
#ifndef SUBSURFACE_MOBILE
rulerItem->setAxis(timeAxis, profileYAxis);
// show the deco model parameters at the top in the center // show the deco model parameters at the top in the center
decoModelParameters->setY(0); decoModelParameters->setY(0);
decoModelParameters->setX(50); decoModelParameters->setX(50);
decoModelParameters->setBrush(getColor(PRESSURE_TEXT)); decoModelParameters->setBrush(getColor(PRESSURE_TEXT));
decoModelParameters->setAlignment(Qt::AlignHCenter | Qt::AlignBottom); decoModelParameters->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
setupItem(reportedCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1);
setupItem(diveCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1); setupItem(diveCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1);
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue(this); DiveCalculatedTissue *tissueItem = new DiveCalculatedTissue(this);
@ -316,15 +329,17 @@ void ProfileWidget2::setupItemOnScene()
setupItem(percentageItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::PERCENTAGE_1 + i, DivePlotDataModel::TIME, 1 + i); setupItem(percentageItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::PERCENTAGE_1 + i, DivePlotDataModel::TIME, 1 + i);
allPercentages.append(percentageItem); allPercentages.append(percentageItem);
} }
setupItem(gasPressureItem, timeAxis, cylinderPressureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1);
setupItem(temperatureItem, timeAxis, temperatureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1);
setupItem(heartBeatItem, timeAxis, heartBeatAxis, dataModel, DivePlotDataModel::HEARTBEAT, DivePlotDataModel::TIME, 1); setupItem(heartBeatItem, timeAxis, heartBeatAxis, dataModel, DivePlotDataModel::HEARTBEAT, DivePlotDataModel::TIME, 1);
setupItem(ambPressureItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::AMBPRESSURE, DivePlotDataModel::TIME, 1); setupItem(ambPressureItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::AMBPRESSURE, DivePlotDataModel::TIME, 1);
setupItem(gflineItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::GFLINE, DivePlotDataModel::TIME, 1); setupItem(gflineItem, timeAxis, percentageAxis, dataModel, DivePlotDataModel::GFLINE, DivePlotDataModel::TIME, 1);
#endif
setupItem(reportedCeiling, timeAxis, profileYAxis, dataModel, DivePlotDataModel::CEILING, DivePlotDataModel::TIME, 1);
setupItem(gasPressureItem, timeAxis, cylinderPressureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1);
setupItem(temperatureItem, timeAxis, temperatureAxis, dataModel, DivePlotDataModel::TEMPERATURE, DivePlotDataModel::TIME, 1);
setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0); setupItem(diveProfileItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::DEPTH, DivePlotDataModel::TIME, 0);
setupItem(meanDepthItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::INSTANT_MEANDEPTH, DivePlotDataModel::TIME, 1); setupItem(meanDepthItem, timeAxis, profileYAxis, dataModel, DivePlotDataModel::INSTANT_MEANDEPTH, DivePlotDataModel::TIME, 1);
#ifndef SUBSURFACE_MOBILE
#define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS) \ #define CREATE_PP_GAS(ITEM, VERTICAL_COLUMN, COLOR, COLOR_ALERT, THRESHOULD_SETTINGS) \
setupItem(ITEM, timeAxis, gasYAxis, dataModel, DivePlotDataModel::VERTICAL_COLUMN, DivePlotDataModel::TIME, 0); \ setupItem(ITEM, timeAxis, gasYAxis, dataModel, DivePlotDataModel::VERTICAL_COLUMN, DivePlotDataModel::TIME, 0); \
ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS); \ ITEM->setThreshouldSettingsKey(THRESHOULD_SETTINGS); \
@ -353,6 +368,11 @@ void ProfileWidget2::setupItemOnScene()
connect(SettingsObjectWrapper::instance()->techDetails, &TechnicalDetailsSettings::showCCRSensorsChanged, ccrsensor3GasItem, &PartialPressureGasItem::setVisible); connect(SettingsObjectWrapper::instance()->techDetails, &TechnicalDetailsSettings::showCCRSensorsChanged, ccrsensor3GasItem, &PartialPressureGasItem::setVisible);
#undef CREATE_PP_GAS #undef CREATE_PP_GAS
heartBeatAxis->setTextVisible(true);
heartBeatAxis->setLinesVisible(true);
percentageAxis->setTextVisible(true);
percentageAxis->setLinesVisible(true);
#endif
temperatureAxis->setTextVisible(false); temperatureAxis->setTextVisible(false);
temperatureAxis->setLinesVisible(false); temperatureAxis->setLinesVisible(false);
cylinderPressureAxis->setTextVisible(false); cylinderPressureAxis->setTextVisible(false);
@ -360,10 +380,6 @@ void ProfileWidget2::setupItemOnScene()
timeAxis->setLinesVisible(true); timeAxis->setLinesVisible(true);
profileYAxis->setLinesVisible(true); profileYAxis->setLinesVisible(true);
gasYAxis->setZValue(timeAxis->zValue() + 1); gasYAxis->setZValue(timeAxis->zValue() + 1);
heartBeatAxis->setTextVisible(true);
heartBeatAxis->setLinesVisible(true);
percentageAxis->setTextVisible(true);
percentageAxis->setLinesVisible(true);
replotEnabled = true; replotEnabled = true;
} }
@ -539,6 +555,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
// this copies the dive and makes copies of all the relevant additional data // this copies the dive and makes copies of all the relevant additional data
copy_dive(d, &displayed_dive); copy_dive(d, &displayed_dive);
#ifndef SUBSURFACE_MOBILE
if (prefs.deco_mode == VPMB) if (prefs.deco_mode == VPMB)
decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.conservatism_level)); decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.conservatism_level));
else else
@ -555,6 +572,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.conservatism_level)); decoModelParameters->setText(QString("VPM-B +%1").arg(prefs.conservatism_level));
else else
decoModelParameters->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh)); decoModelParameters->setText(QString("GF %1/%2").arg(prefs.gflow).arg(prefs.gfhigh));
#endif
} }
// special handling for the first time we display things // special handling for the first time we display things
@ -587,10 +605,12 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
bool setpointflag = (currentdc->divemode == CCR) && prefs.pp_graphs.po2 && current_dive; bool setpointflag = (currentdc->divemode == CCR) && prefs.pp_graphs.po2 && current_dive;
bool sensorflag = setpointflag && prefs.show_ccr_sensors; bool sensorflag = setpointflag && prefs.show_ccr_sensors;
#ifndef SUBSURFACE_MOBILE
o2SetpointGasItem->setVisible(setpointflag && prefs.show_ccr_setpoint); o2SetpointGasItem->setVisible(setpointflag && prefs.show_ccr_setpoint);
ccrsensor1GasItem->setVisible(sensorflag); ccrsensor1GasItem->setVisible(sensorflag);
ccrsensor2GasItem->setVisible(sensorflag && (currentdc->no_o2sensors > 1)); ccrsensor2GasItem->setVisible(sensorflag && (currentdc->no_o2sensors > 1));
ccrsensor3GasItem->setVisible(sensorflag && (currentdc->no_o2sensors > 2)); ccrsensor3GasItem->setVisible(sensorflag && (currentdc->no_o2sensors > 2));
#endif
/* This struct holds all the data that's about to be plotted. /* This struct holds all the data that's about to be plotted.
* I'm not sure this is the best approach ( but since we are * I'm not sure this is the best approach ( but since we are
@ -629,6 +649,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
temperatureAxis->setMinimum(plotInfo.mintemp); temperatureAxis->setMinimum(plotInfo.mintemp);
temperatureAxis->setMaximum(plotInfo.maxtemp - plotInfo.mintemp > 2000 ? plotInfo.maxtemp : plotInfo.mintemp + 2000); temperatureAxis->setMaximum(plotInfo.maxtemp - plotInfo.mintemp > 2000 ? plotInfo.maxtemp : plotInfo.mintemp + 2000);
#ifndef SUBSURFACE_MOBILE
if (plotInfo.maxhr) { if (plotInfo.maxhr) {
heartBeatAxis->setMinimum(plotInfo.minhr); heartBeatAxis->setMinimum(plotInfo.minhr);
heartBeatAxis->setMaximum(plotInfo.maxhr); heartBeatAxis->setMaximum(plotInfo.maxhr);
@ -640,7 +661,7 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
percentageAxis->setMaximum(100); percentageAxis->setMaximum(100);
percentageAxis->setVisible(false); percentageAxis->setVisible(false);
percentageAxis->updateTicks(HR_AXIS); percentageAxis->updateTicks(HR_AXIS);
#endif
timeAxis->setMaximum(maxtime); timeAxis->setMaximum(maxtime);
int i, incr; int i, incr;
static int increments[8] = { 10, 20, 30, 60, 5 * 60, 10 * 60, 15 * 60, 30 * 60 }; static int increments[8] = { 10, 20, 30, 60, 5 * 60, 10 * 60, 15 * 60, 30 * 60 };
@ -661,8 +682,9 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
timeAxis->updateTicks(); timeAxis->updateTicks();
cylinderPressureAxis->setMinimum(plotInfo.minpressure); cylinderPressureAxis->setMinimum(plotInfo.minpressure);
cylinderPressureAxis->setMaximum(plotInfo.maxpressure); cylinderPressureAxis->setMaximum(plotInfo.maxpressure);
#ifndef SUBSURFACE_MOBILE
rulerItem->setPlotInfo(plotInfo); rulerItem->setPlotInfo(plotInfo);
#endif
tankItem->setData(dataModel, &plotInfo, &displayed_dive); tankItem->setData(dataModel, &plotInfo, &displayed_dive);
dataModel->emitDataChanged(); dataModel->emitDataChanged();
@ -736,7 +758,9 @@ void ProfileWidget2::plotDive(struct dive *d, bool force)
void ProfileWidget2::recalcCeiling() void ProfileWidget2::recalcCeiling()
{ {
#ifndef SUBSURFACE_MOBILE
diveCeiling->recalc(); diveCeiling->recalc();
#endif
} }
void ProfileWidget2::dateTimeChanged() void ProfileWidget2::dateTimeChanged()
@ -755,6 +779,7 @@ void ProfileWidget2::settingsChanged()
// if we are showing calculated ceilings then we have to replot() // if we are showing calculated ceilings then we have to replot()
// because the GF could have changed; otherwise we try to avoid replot() // because the GF could have changed; otherwise we try to avoid replot()
bool needReplot = prefs.calcceiling; bool needReplot = prefs.calcceiling;
#ifndef SUBSURFACE_MOBILE
if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) { if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) {
profileYAxis->animateChangeLine(itemPos.depth.shrinked); profileYAxis->animateChangeLine(itemPos.depth.shrinked);
temperatureAxis->setPos(itemPos.temperatureAll.pos.on); temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
@ -796,6 +821,9 @@ void ProfileWidget2::settingsChanged()
heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded); heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
} }
} else { } else {
#else
{
#endif
profileYAxis->animateChangeLine(itemPos.depth.expanded); profileYAxis->animateChangeLine(itemPos.depth.expanded);
if (prefs.tankbar) { if (prefs.tankbar) {
temperatureAxis->setPos(itemPos.temperatureAll.pos.on); temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
@ -822,6 +850,7 @@ void ProfileWidget2::resizeEvent(QResizeEvent *event)
fixBackgroundPos(); fixBackgroundPos();
} }
#ifndef SUBSURFACE_MOBILE
void ProfileWidget2::mousePressEvent(QMouseEvent *event) void ProfileWidget2::mousePressEvent(QMouseEvent *event)
{ {
if (zoomLevel) if (zoomLevel)
@ -831,7 +860,6 @@ void ProfileWidget2::mousePressEvent(QMouseEvent *event)
shouldCalculateMaxTime = false; shouldCalculateMaxTime = false;
} }
#ifndef SUBSURFACE_MOBILE
void ProfileWidget2::divePlannerHandlerClicked() void ProfileWidget2::divePlannerHandlerClicked()
{ {
if (zoomLevel) if (zoomLevel)
@ -847,7 +875,6 @@ void ProfileWidget2::divePlannerHandlerReleased()
shouldCalculateMaxDepth = true; shouldCalculateMaxDepth = true;
replot(); replot();
} }
#endif
void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event) void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event)
{ {
@ -859,6 +886,7 @@ void ProfileWidget2::mouseReleaseEvent(QMouseEvent *event)
replot(); replot();
} }
} }
#endif
void ProfileWidget2::fixBackgroundPos() void ProfileWidget2::fixBackgroundPos()
{ {
@ -873,6 +901,7 @@ void ProfileWidget2::fixBackgroundPos()
background->setY(mapToScene(y, 20).y()); background->setY(mapToScene(y, 20).y());
} }
#ifndef SUBSURFACE_MOBILE
void ProfileWidget2::wheelEvent(QWheelEvent *event) void ProfileWidget2::wheelEvent(QWheelEvent *event)
{ {
if (currentState == EMPTY) if (currentState == EMPTY)
@ -944,6 +973,7 @@ void ProfileWidget2::mouseMoveEvent(QMouseEvent *event)
qreal vValue = profileYAxis->valueAt(pos); qreal vValue = profileYAxis->valueAt(pos);
qreal hValue = timeAxis->valueAt(pos); qreal hValue = timeAxis->valueAt(pos);
if (profileYAxis->maximum() >= vValue && profileYAxis->minimum() <= vValue) { if (profileYAxis->maximum() >= vValue && profileYAxis->minimum() <= vValue) {
mouseFollowerHorizontal->setPos(timeAxis->pos().x(), pos.y()); mouseFollowerHorizontal->setPos(timeAxis->pos().x(), pos.y());
} }
@ -961,6 +991,7 @@ bool ProfileWidget2::eventFilter(QObject *object, QEvent *event)
} }
return QGraphicsView::eventFilter(object, event); return QGraphicsView::eventFilter(object, event);
} }
#endif
void ProfileWidget2::setEmptyState() void ProfileWidget2::setEmptyState()
{ {
@ -982,13 +1013,14 @@ void ProfileWidget2::setEmptyState()
timeAxis->setVisible(false); timeAxis->setVisible(false);
temperatureAxis->setVisible(false); temperatureAxis->setVisible(false);
cylinderPressureAxis->setVisible(false); cylinderPressureAxis->setVisible(false);
toolTipItem->setVisible(false);
diveComputerText->setVisible(false); diveComputerText->setVisible(false);
reportedCeiling->setVisible(false);
tankItem->setVisible(false);
#ifndef SUBSURFACE_MOBILE
toolTipItem->setVisible(false);
diveCeiling->setVisible(false); diveCeiling->setVisible(false);
decoModelParameters->setVisible(false); decoModelParameters->setVisible(false);
reportedCeiling->setVisible(false);
rulerItem->setVisible(false); rulerItem->setVisible(false);
tankItem->setVisible(false);
pn2GasItem->setVisible(false); pn2GasItem->setVisible(false);
po2GasItem->setVisible(false); po2GasItem->setVisible(false);
o2SetpointGasItem->setVisible(false); o2SetpointGasItem->setVisible(false);
@ -1002,11 +1034,14 @@ void ProfileWidget2::setEmptyState()
mouseFollowerVertical->setVisible(false); mouseFollowerVertical->setVisible(false);
heartBeatAxis->setVisible(false); heartBeatAxis->setVisible(false);
heartBeatItem->setVisible(false); heartBeatItem->setVisible(false);
#endif
#define HIDE_ALL(TYPE, CONTAINER) \ #define HIDE_ALL(TYPE, CONTAINER) \
Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false); Q_FOREACH (TYPE *item, CONTAINER) item->setVisible(false);
#ifndef SUBSURFACE_MOBILE
HIDE_ALL(DiveCalculatedTissue, allTissues); HIDE_ALL(DiveCalculatedTissue, allTissues);
HIDE_ALL(DivePercentageItem, allPercentages); HIDE_ALL(DivePercentageItem, allPercentages);
#endif
HIDE_ALL(DiveEventItem, eventItems); HIDE_ALL(DiveEventItem, eventItems);
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
HIDE_ALL(DiveHandler, handles); HIDE_ALL(DiveHandler, handles);
@ -1031,11 +1066,9 @@ void ProfileWidget2::setProfileState()
currentState = PROFILE; currentState = PROFILE;
emit enableToolbar(true); emit enableToolbar(true);
toolTipItem->readPos();
setBackgroundBrush(getColor(::BACKGROUND, isGrayscale)); setBackgroundBrush(getColor(::BACKGROUND, isGrayscale));
background->setVisible(false); background->setVisible(false);
toolTipItem->setVisible(true);
profileYAxis->setVisible(true); profileYAxis->setVisible(true);
gasYAxis->setVisible(true); gasYAxis->setVisible(true);
timeAxis->setVisible(true); timeAxis->setVisible(true);
@ -1043,6 +1076,9 @@ void ProfileWidget2::setProfileState()
cylinderPressureAxis->setVisible(true); cylinderPressureAxis->setVisible(true);
profileYAxis->setPos(itemPos.depth.pos.on); profileYAxis->setPos(itemPos.depth.pos.on);
#ifndef SUBSURFACE_MOBILE
toolTipItem->readPos();
toolTipItem->setVisible(true);
if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) { if ((prefs.percentagegraph||prefs.hrgraph) && PP_GRAPHS_ENABLED) {
profileYAxis->animateChangeLine(itemPos.depth.shrinked); profileYAxis->animateChangeLine(itemPos.depth.shrinked);
temperatureAxis->setPos(itemPos.temperatureAll.pos.on); temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
@ -1084,6 +1120,9 @@ void ProfileWidget2::setProfileState()
heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded); heartBeatAxis->animateChangeLine(itemPos.heartBeat.expanded);
} }
} else { } else {
#else
{
#endif
profileYAxis->animateChangeLine(itemPos.depth.expanded); profileYAxis->animateChangeLine(itemPos.depth.expanded);
if (prefs.tankbar) { if (prefs.tankbar) {
temperatureAxis->setPos(itemPos.temperatureAll.pos.on); temperatureAxis->setPos(itemPos.temperatureAll.pos.on);
@ -1093,6 +1132,7 @@ void ProfileWidget2::setProfileState()
temperatureAxis->animateChangeLine(itemPos.temperature.expanded); temperatureAxis->animateChangeLine(itemPos.temperature.expanded);
cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded); cylinderPressureAxis->animateChangeLine(itemPos.cylinder.expanded);
} }
#ifndef SUBSURFACE_MOBILE
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);
@ -1104,26 +1144,15 @@ void ProfileWidget2::setProfileState()
ccrsensor2GasItem->setVisible(sensorflag && (current_dc->no_o2sensors > 1)); ccrsensor2GasItem->setVisible(sensorflag && (current_dc->no_o2sensors > 1));
ccrsensor3GasItem->setVisible(sensorflag && (current_dc->no_o2sensors > 2)); ccrsensor3GasItem->setVisible(sensorflag && (current_dc->no_o2sensors > 2));
timeAxis->setPos(itemPos.time.pos.on);
timeAxis->setLine(itemPos.time.expanded);
cylinderPressureAxis->setPos(itemPos.cylinder.pos.on);
heartBeatItem->setVisible(prefs.hrgraph); heartBeatItem->setVisible(prefs.hrgraph);
meanDepthItem->setVisible(prefs.show_average_depth);
diveComputerText->setVisible(true);
diveComputerText->setPos(itemPos.dcLabel.on);
diveCeiling->setVisible(prefs.calcceiling); diveCeiling->setVisible(prefs.calcceiling);
decoModelParameters->setVisible(prefs.calcceiling); decoModelParameters->setVisible(prefs.calcceiling);
reportedCeiling->setVisible(prefs.dcceiling);
if (prefs.calcalltissues) { if (prefs.calcalltissues) {
Q_FOREACH (DiveCalculatedTissue *tissue, allTissues) { Q_FOREACH (DiveCalculatedTissue *tissue, allTissues) {
tissue->setVisible(true); tissue->setVisible(true);
} }
} }
if (prefs.percentagegraph) { if (prefs.percentagegraph) {
Q_FOREACH (DivePercentageItem *percentage, allPercentages) { Q_FOREACH (DivePercentageItem *percentage, allPercentages) {
percentage->setVisible(true); percentage->setVisible(true);
@ -1134,6 +1163,19 @@ void ProfileWidget2::setProfileState()
} }
rulerItem->setVisible(prefs.rulergraph); rulerItem->setVisible(prefs.rulergraph);
#endif
timeAxis->setPos(itemPos.time.pos.on);
timeAxis->setLine(itemPos.time.expanded);
cylinderPressureAxis->setPos(itemPos.cylinder.pos.on);
meanDepthItem->setVisible(prefs.show_average_depth);
diveComputerText->setVisible(true);
diveComputerText->setPos(itemPos.dcLabel.on);
reportedCeiling->setVisible(prefs.dcceiling);
tankItem->setVisible(prefs.tankbar); tankItem->setVisible(prefs.tankbar);
tankItem->setPos(itemPos.tankBar.on); tankItem->setPos(itemPos.tankBar.on);
@ -1142,11 +1184,11 @@ void ProfileWidget2::setProfileState()
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
HIDE_ALL(DiveHandler, handles); HIDE_ALL(DiveHandler, handles);
mouseFollowerHorizontal->setVisible(false);
mouseFollowerVertical->setVisible(false);
#endif #endif
HIDE_ALL(QGraphicsSimpleTextItem, gases); HIDE_ALL(QGraphicsSimpleTextItem, gases);
#undef HIDE_ALL #undef HIDE_ALL
mouseFollowerHorizontal->setVisible(false);
mouseFollowerVertical->setVisible(false);
} }
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
@ -1160,7 +1202,6 @@ void ProfileWidget2::clearHandlers()
handles.clear(); handles.clear();
} }
} }
#endif
void ProfileWidget2::setToolTipVisibile(bool visible) void ProfileWidget2::setToolTipVisibile(bool visible)
{ {
@ -1172,9 +1213,7 @@ void ProfileWidget2::setAddState()
if (currentState == ADD) if (currentState == ADD)
return; return;
#ifndef SUBSURFACE_MOBILE
clearHandlers(); clearHandlers();
#endif
setProfileState(); setProfileState();
mouseFollowerHorizontal->setVisible(true); mouseFollowerHorizontal->setVisible(true);
mouseFollowerVertical->setVisible(true); mouseFollowerVertical->setVisible(true);
@ -1237,6 +1276,7 @@ void ProfileWidget2::setPlanState()
decoModelParameters->setVisible(true); decoModelParameters->setVisible(true);
setBackgroundBrush(QColor("#D7E3EF")); setBackgroundBrush(QColor("#D7E3EF"));
} }
#endif
extern struct ev_select *ev_namelist; extern struct ev_select *ev_namelist;
extern int evn_allocated; extern int evn_allocated;
@ -1558,13 +1598,15 @@ void ProfileWidget2::setPrintMode(bool mode, bool grayscale)
temperatureAxis->setPrintMode(mode); temperatureAxis->setPrintMode(mode);
timeAxis->setPrintMode(mode); timeAxis->setPrintMode(mode);
cylinderPressureAxis->setPrintMode(mode); cylinderPressureAxis->setPrintMode(mode);
isGrayscale = mode ? grayscale : false;
#ifndef SUBSURFACE_MOBILE
heartBeatAxis->setPrintMode(mode); heartBeatAxis->setPrintMode(mode);
percentageAxis->setPrintMode(mode); percentageAxis->setPrintMode(mode);
isGrayscale = mode ? grayscale : false;
mouseFollowerHorizontal->setVisible(!mode); mouseFollowerHorizontal->setVisible(!mode);
mouseFollowerVertical->setVisible(!mode); mouseFollowerVertical->setVisible(!mode);
toolTipItem->setVisible(!mode); toolTipItem->setVisible(!mode);
#endif
} }
void ProfileWidget2::setFontPrintScale(double scale) void ProfileWidget2::setFontPrintScale(double scale)

View file

@ -72,7 +72,6 @@ public:
ProfileWidget2(QWidget *parent = 0); ProfileWidget2(QWidget *parent = 0);
void resetZoom(); void resetZoom();
void plotDive(struct dive *d = 0, bool force = false); void plotDive(struct dive *d = 0, bool force = false);
virtual bool eventFilter(QObject *, QEvent *);
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue); void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *hAxis, DiveCartesianAxis *vAxis, DivePlotDataModel *model, int vData, int hData, int zValue);
void setPrintMode(bool mode, bool grayscale = false); void setPrintMode(bool mode, bool grayscale = false);
bool getPrintMode(); bool getPrintMode();
@ -82,6 +81,7 @@ public:
double getFontPrintScale(); double getFontPrintScale();
void setFontPrintScale(double scale); void setFontPrintScale(double scale);
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
virtual bool eventFilter(QObject *, QEvent *);
void clearHandlers(); void clearHandlers();
#endif #endif
void recalcCeiling(); void recalcCeiling();
@ -106,12 +106,12 @@ slots: // Necessary to call from QAction's signals.
void actionRequestedReplot(bool triggered); void actionRequestedReplot(bool triggered);
void setEmptyState(); void setEmptyState();
void setProfileState(); void setProfileState();
void setPlanState();
void setAddState();
void plotPictures(); void plotPictures();
void setReplot(bool state); void setReplot(bool state);
void replot(dive *d = 0); void replot(dive *d = 0);
#ifndef SUBSURFACE_MOBILE #ifndef SUBSURFACE_MOBILE
void setPlanState();
void setAddState();
void changeGas(); void changeGas();
void addSetpointChange(); void addSetpointChange();
void addBookmark(); void addBookmark();
@ -142,14 +142,14 @@ slots: // Necessary to call from QAction's signals.
protected: protected:
virtual ~ProfileWidget2(); virtual ~ProfileWidget2();
virtual void resizeEvent(QResizeEvent *event); virtual void resizeEvent(QResizeEvent *event);
#ifndef SUBSURFACE_MOBILE
virtual void wheelEvent(QWheelEvent *event); virtual void wheelEvent(QWheelEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event); virtual void mouseMoveEvent(QMouseEvent *event);
#ifndef SUBSURFACE_MOBILE
virtual void contextMenuEvent(QContextMenuEvent *event); virtual void contextMenuEvent(QContextMenuEvent *event);
#endif
virtual void mouseDoubleClickEvent(QMouseEvent *event); virtual void mouseDoubleClickEvent(QMouseEvent *event);
virtual void mousePressEvent(QMouseEvent *event); virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event); virtual void mouseReleaseEvent(QMouseEvent *event);
#endif
void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE; void dropEvent(QDropEvent *event) Q_DECL_OVERRIDE;
void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE; void dragEnterEvent(QDragEnterEvent *event) Q_DECL_OVERRIDE;
void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE; void dragMoveEvent(QDragMoveEvent *event) Q_DECL_OVERRIDE;
@ -171,7 +171,9 @@ private:
qreal zoomFactor; qreal zoomFactor;
DivePixmapItem *background; DivePixmapItem *background;
QString backgroundFile; QString backgroundFile;
#ifndef SUBSURFACE_MOBILE
ToolTipItem *toolTipItem; ToolTipItem *toolTipItem;
#endif
bool isPlotZoomed; bool isPlotZoomed;
bool replotEnabled; bool replotEnabled;
// All those here should probably be merged into one structure, // All those here should probably be merged into one structure,
@ -189,10 +191,11 @@ private:
DiveGasPressureItem *gasPressureItem; DiveGasPressureItem *gasPressureItem;
QList<DiveEventItem *> eventItems; QList<DiveEventItem *> eventItems;
DiveTextItem *diveComputerText; DiveTextItem *diveComputerText;
DiveReportedCeiling *reportedCeiling;
#ifndef SUBSURFACE_MOBILE
DiveCalculatedCeiling *diveCeiling; DiveCalculatedCeiling *diveCeiling;
DiveTextItem *decoModelParameters; DiveTextItem *decoModelParameters;
QList<DiveCalculatedTissue *> allTissues; QList<DiveCalculatedTissue *> allTissues;
DiveReportedCeiling *reportedCeiling;
PartialPressureGasItem *pn2GasItem; PartialPressureGasItem *pn2GasItem;
PartialPressureGasItem *pheGasItem; PartialPressureGasItem *pheGasItem;
PartialPressureGasItem *po2GasItem; PartialPressureGasItem *po2GasItem;
@ -209,6 +212,7 @@ private:
DiveLineItem *mouseFollowerVertical; DiveLineItem *mouseFollowerVertical;
DiveLineItem *mouseFollowerHorizontal; DiveLineItem *mouseFollowerHorizontal;
RulerItem2 *rulerItem; RulerItem2 *rulerItem;
#endif
TankItem *tankItem; TankItem *tankItem;
bool isGrayscale; bool isGrayscale;
bool printMode; bool printMode;