aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-12-20 18:58:09 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2021-01-10 15:57:39 -0800
commit991a94d14c22c103fedfa7df7162b82ad20e0e67 (patch)
tree3ea80d8d72f54a67ae4316d32fdf57b5fb91aac8
parente3ea74e079d469dff47ee05216bb049ef005d50a (diff)
downloadsubsurface-991a94d14c22c103fedfa7df7162b82ad20e0e67.tar.gz
profile: remove ProfileWidget2::setupItem()
The only thing left that this function did, was setting the Z-value of the item. This can be done directly on construction. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--profile-widget/profilewidget2.cpp46
-rw-r--r--profile-widget/profilewidget2.h3
2 files changed, 15 insertions, 34 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index 5ccb27592..14dd23d08 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -97,10 +97,11 @@ static const double thumbnailBaseZValue = 100.0;
#endif
template<typename T, class... Args>
-T *ProfileWidget2::createItem(const DiveCartesianAxis &vAxis, int vColumn, Args&&... args)
+T *ProfileWidget2::createItem(const DiveCartesianAxis &vAxis, int vColumn, int z, Args&&... args)
{
T *res = new T(*dataModel, *timeAxis, DivePlotDataModel::TIME, vAxis, vColumn,
std::forward<Args>(args)...);
+ res->setZValue(static_cast<double>(z));
return res;
}
@@ -121,13 +122,13 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
gasYAxis(new PartialGasPressureAxis(this)),
temperatureAxis(new TemperatureAxis(this)),
timeAxis(new TimeAxis(this)),
- diveProfileItem(createItem<DiveProfileItem>(*profileYAxis, DivePlotDataModel::DEPTH)),
- temperatureItem(createItem<DiveTemperatureItem>(*temperatureAxis, DivePlotDataModel::TEMPERATURE)),
- meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH)),
+ diveProfileItem(createItem<DiveProfileItem>(*profileYAxis, DivePlotDataModel::DEPTH, 0)),
+ temperatureItem(createItem<DiveTemperatureItem>(*temperatureAxis, DivePlotDataModel::TEMPERATURE, 1)),
+ meanDepthItem(createItem<DiveMeanDepthItem>(*profileYAxis, DivePlotDataModel::INSTANT_MEANDEPTH, 1)),
cylinderPressureAxis(new DiveCartesianAxis(this)),
- gasPressureItem(createItem<DiveGasPressureItem>(*cylinderPressureAxis, DivePlotDataModel::TEMPERATURE)),
+ gasPressureItem(createItem<DiveGasPressureItem>(*cylinderPressureAxis, DivePlotDataModel::TEMPERATURE, 1)),
diveComputerText(new DiveTextItem()),
- reportedCeiling(createItem<DiveReportedCeiling>(*profileYAxis, DivePlotDataModel::CEILING)),
+ reportedCeiling(createItem<DiveReportedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1)),
pn2GasItem(createPPGas(DivePlotDataModel::PN2, PN2, PN2_ALERT, NULL, &prefs.pp_graphs.pn2_threshold)),
pheGasItem(createPPGas(DivePlotDataModel::PHE, PHE, PHE_ALERT, NULL, &prefs.pp_graphs.phe_threshold)),
po2GasItem(createPPGas(DivePlotDataModel::PO2, PO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)),
@@ -136,15 +137,14 @@ ProfileWidget2::ProfileWidget2(QWidget *parent) : QGraphicsView(parent),
ccrsensor2GasItem(createPPGas(DivePlotDataModel::CCRSENSOR2, CCRSENSOR2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)),
ccrsensor3GasItem(createPPGas(DivePlotDataModel::CCRSENSOR3, CCRSENSOR3, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)),
ocpo2GasItem(createPPGas(DivePlotDataModel::SCR_OC_PO2, SCR_OCPO2, PO2_ALERT, &prefs.pp_graphs.po2_threshold_min, &prefs.pp_graphs.po2_threshold_max)),
-
#ifndef SUBSURFACE_MOBILE
- diveCeiling(createItem<DiveCalculatedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, this)),
+ diveCeiling(createItem<DiveCalculatedCeiling>(*profileYAxis, DivePlotDataModel::CEILING, 1, this)),
decoModelParameters(new DiveTextItem()),
heartBeatAxis(new DiveCartesianAxis(this)),
- heartBeatItem(createItem<DiveHeartrateItem>(*heartBeatAxis, DivePlotDataModel::HEARTBEAT)),
+ heartBeatItem(createItem<DiveHeartrateItem>(*heartBeatAxis, DivePlotDataModel::HEARTBEAT, 1)),
percentageAxis(new DiveCartesianAxis(this)),
- ambPressureItem(createItem<DiveAmbPressureItem>(*percentageAxis, DivePlotDataModel::AMBPRESSURE)),
- gflineItem(createItem<DiveGFLineItem>(*percentageAxis, DivePlotDataModel::GFLINE)),
+ ambPressureItem(createItem<DiveAmbPressureItem>(*percentageAxis, DivePlotDataModel::AMBPRESSURE, 1)),
+ gflineItem(createItem<DiveGFLineItem>(*percentageAxis, DivePlotDataModel::GFLINE, 1)),
mouseFollowerVertical(new DiveLineItem()),
mouseFollowerHorizontal(new DiveLineItem()),
rulerItem(new RulerItem2()),
@@ -349,24 +349,13 @@ void ProfileWidget2::setupItemOnScene()
decoModelParameters->setX(50);
decoModelParameters->setBrush(getColor(PRESSURE_TEXT));
decoModelParameters->setAlignment(Qt::AlignHCenter | Qt::AlignBottom);
- setupItem(diveCeiling, 1);
for (int i = 0; i < 16; i++) {
- DiveCalculatedTissue *tissueItem = createItem<DiveCalculatedTissue>(*profileYAxis, DivePlotDataModel::TISSUE_1 + i, this);
- setupItem(tissueItem, 1 + i);
+ DiveCalculatedTissue *tissueItem = createItem<DiveCalculatedTissue>(*profileYAxis, DivePlotDataModel::TISSUE_1 + i, i + 1, this);
allTissues.append(tissueItem);
- DivePercentageItem *percentageItem = createItem<DivePercentageItem>(*percentageAxis, DivePlotDataModel::PERCENTAGE_1 + i, i);
- setupItem(percentageItem, 1 + i);
+ DivePercentageItem *percentageItem = createItem<DivePercentageItem>(*percentageAxis, DivePlotDataModel::PERCENTAGE_1 + i, i + 1, i);
allPercentages.append(percentageItem);
}
- setupItem(heartBeatItem, 1);
- setupItem(ambPressureItem, 1);
- setupItem(gflineItem, 1);
#endif
- setupItem(reportedCeiling, 1);
- setupItem(gasPressureItem, 1);
- setupItem(temperatureItem, 1);
- setupItem(diveProfileItem, 0);
- setupItem(meanDepthItem, 1);
#undef CREATE_PP_GAS
#ifndef SUBSURFACE_MOBILE
@@ -405,12 +394,10 @@ void ProfileWidget2::replot()
PartialPressureGasItem *ProfileWidget2::createPPGas(int column, color_index_t color, color_index_t colorAlert,
const double *thresholdSettingsMin, const double *thresholdSettingsMax)
{
- PartialPressureGasItem *item = createItem<PartialPressureGasItem>(*gasYAxis, column);
- setupItem(item, 0);
+ PartialPressureGasItem *item = createItem<PartialPressureGasItem>(*gasYAxis, column, 99);
item->setThresholdSettingsKey(thresholdSettingsMin, thresholdSettingsMax);
item->setColors(getColor(color, isGrayscale), getColor(colorAlert, isGrayscale));
item->settingsChanged();
- item->setZValue(99);
return item;
}
@@ -539,11 +526,6 @@ void ProfileWidget2::setupItemSizes()
#endif
}
-void ProfileWidget2::setupItem(AbstractProfilePolygonItem *item, int zValue)
-{
- item->setZValue(zValue);
-}
-
void ProfileWidget2::setupSceneAndFlags()
{
setScene(new QGraphicsScene(this));
diff --git a/profile-widget/profilewidget2.h b/profile-widget/profilewidget2.h
index 9da3d80b7..a54ede567 100644
--- a/profile-widget/profilewidget2.h
+++ b/profile-widget/profilewidget2.h
@@ -78,7 +78,6 @@ public:
void resetZoom();
void scale(qreal sx, qreal sy);
void plotDive(const struct dive *d, bool force = false, bool clearPictures = false, bool instant = false);
- void setupItem(AbstractProfilePolygonItem *item, int zValue);
void setPrintMode(bool mode, bool grayscale = false);
bool getPrintMode();
bool isPointOutOfBoundaries(const QPointF &point) const;
@@ -152,7 +151,7 @@ private:
void fixBackgroundPos();
void scrollViewTo(const QPoint &pos);
void setupSceneAndFlags();
- template<typename T, class... Args> T *createItem(const DiveCartesianAxis &vAxis, int vColumn, Args&&... args);
+ template<typename T, class... Args> T *createItem(const DiveCartesianAxis &vAxis, int vColumn, int z, Args&&... args);
void setupItemSizes();
void addItemsToScene();
void setupItemOnScene();