2021-08-03 13:39:25 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
// Displays the dive profile. Used by the interactive profile widget
|
|
|
|
// and the printing/exporting code.
|
2021-06-05 16:42:56 +00:00
|
|
|
#ifndef PROFILESCENE_H
|
|
|
|
#define PROFILESCENE_H
|
|
|
|
|
2021-08-03 07:51:37 +00:00
|
|
|
#include "core/color.h"
|
2022-03-12 10:11:04 +00:00
|
|
|
#include "core/profile.h"
|
2021-08-03 07:51:37 +00:00
|
|
|
|
2021-06-05 16:42:56 +00:00
|
|
|
#include <QGraphicsScene>
|
2021-08-04 05:27:41 +00:00
|
|
|
#include <QPainter>
|
2021-08-30 19:11:11 +00:00
|
|
|
#include <memory>
|
2021-06-05 16:42:56 +00:00
|
|
|
|
2021-08-03 07:51:37 +00:00
|
|
|
class AbstractProfilePolygonItem;
|
|
|
|
class DiveCalculatedCeiling;
|
|
|
|
class DiveCalculatedTissue;
|
|
|
|
class DiveCartesianAxis;
|
|
|
|
class DiveEventItem;
|
|
|
|
class DiveGasPressureItem;
|
|
|
|
class DiveHeartrateItem;
|
|
|
|
class DiveMeanDepthItem;
|
|
|
|
class DivePercentageItem;
|
2021-08-30 19:11:11 +00:00
|
|
|
class DivePixmaps;
|
2021-12-03 18:09:39 +00:00
|
|
|
class DivePlannerPointsModel;
|
2021-08-03 07:51:37 +00:00
|
|
|
class DiveProfileItem;
|
|
|
|
class DiveReportedCeiling;
|
|
|
|
class DiveTemperatureItem;
|
|
|
|
class DiveTextItem;
|
|
|
|
class PartialPressureGasItem;
|
2021-12-02 22:53:17 +00:00
|
|
|
class ProfileAnimation;
|
2021-08-03 07:51:37 +00:00
|
|
|
class TankItem;
|
2021-06-28 18:29:46 +00:00
|
|
|
|
2021-06-05 16:42:56 +00:00
|
|
|
class ProfileScene : public QGraphicsScene {
|
|
|
|
public:
|
2021-08-09 14:48:08 +00:00
|
|
|
ProfileScene(double dpr, bool printMode, bool isGrayscale);
|
2021-06-05 16:42:56 +00:00
|
|
|
~ProfileScene();
|
2021-06-28 18:29:46 +00:00
|
|
|
|
2021-08-28 21:36:09 +00:00
|
|
|
void resize(QSizeF size);
|
2021-08-03 07:51:37 +00:00
|
|
|
void clear();
|
2021-10-26 14:37:38 +00:00
|
|
|
bool pointOnProfile(const QPointF &point) const;
|
2021-12-02 22:53:17 +00:00
|
|
|
void anim(double fraction); // Called by the animation with 0.0-1.0 (start to stop).
|
|
|
|
// Can be compared with literal 1.0 to determine "end" state.
|
2021-06-28 18:29:46 +00:00
|
|
|
|
2021-08-03 07:51:37 +00:00
|
|
|
// If a plannerModel is passed, the deco-information is taken from there.
|
|
|
|
void plotDive(const struct dive *d, int dc, DivePlannerPointsModel *plannerModel = nullptr, bool inPlanner = false,
|
2021-10-22 16:23:15 +00:00
|
|
|
bool instant = false, bool keepPlotInfo = false, bool calcMax = true, double zoom = 1.0, double zoomedPosition = 0.0);
|
2021-08-03 07:51:37 +00:00
|
|
|
|
2021-08-30 20:59:45 +00:00
|
|
|
void draw(QPainter *painter, const QRect &pos,
|
|
|
|
const struct dive *d, int dc,
|
|
|
|
DivePlannerPointsModel *plannerModel = nullptr, bool inPlanner = false);
|
2021-08-04 05:27:41 +00:00
|
|
|
|
2021-08-03 07:51:37 +00:00
|
|
|
const struct dive *d;
|
|
|
|
int dc;
|
2021-06-28 18:29:46 +00:00
|
|
|
private:
|
2021-12-03 17:49:49 +00:00
|
|
|
using DataAccessor = double (*)(const plot_data &data);
|
|
|
|
template<typename T, class... Args> T *createItem(const DiveCartesianAxis &vAxis, DataAccessor accessor, int z, Args&&... args);
|
|
|
|
PartialPressureGasItem *createPPGas(DataAccessor accessor, color_index_t color, color_index_t colorAlert,
|
2021-08-03 07:51:37 +00:00
|
|
|
const double *thresholdSettingsMin, const double *thresholdSettingsMax);
|
2021-12-03 17:49:49 +00:00
|
|
|
template <int ACT, int MAX> void addTissueItems(double dpr);
|
2021-10-09 21:22:42 +00:00
|
|
|
void updateVisibility(bool diveHasHeartBeat, bool simplified); // Update visibility of non-interactive chart features according to preferences
|
|
|
|
void updateAxes(bool diveHasHeartBeat, bool simplified); // Update axes according to preferences
|
2021-08-03 07:51:37 +00:00
|
|
|
|
2021-06-28 18:29:46 +00:00
|
|
|
friend class ProfileWidget2; // For now, give the ProfileWidget full access to the objects on the scene
|
2021-08-09 14:48:08 +00:00
|
|
|
double dpr; // Device Pixel Ratio. A DPR of one corresponds to a "standard" PC screen.
|
2021-07-29 04:50:59 +00:00
|
|
|
bool printMode;
|
|
|
|
bool isGrayscale;
|
2021-08-03 07:51:37 +00:00
|
|
|
int maxtime;
|
|
|
|
int maxdepth;
|
2021-07-29 04:50:59 +00:00
|
|
|
|
2021-08-03 07:51:37 +00:00
|
|
|
struct plot_info plotInfo;
|
2021-12-10 11:15:44 +00:00
|
|
|
QRectF profileRegion; // Region inside the axes, where the crosshair is painted in plan and edit mode.
|
2021-10-03 20:10:00 +00:00
|
|
|
DiveCartesianAxis *profileYAxis;
|
2021-09-26 17:30:27 +00:00
|
|
|
DiveCartesianAxis *gasYAxis;
|
2021-10-03 20:10:00 +00:00
|
|
|
DiveCartesianAxis *temperatureAxis;
|
|
|
|
DiveCartesianAxis *timeAxis;
|
2021-06-28 18:29:46 +00:00
|
|
|
DiveCartesianAxis *cylinderPressureAxis;
|
|
|
|
DiveCartesianAxis *heartBeatAxis;
|
|
|
|
DiveCartesianAxis *percentageAxis;
|
2021-08-03 07:51:37 +00:00
|
|
|
std::vector<AbstractProfilePolygonItem *> profileItems;
|
|
|
|
DiveProfileItem *diveProfileItem;
|
|
|
|
DiveTemperatureItem *temperatureItem;
|
|
|
|
DiveMeanDepthItem *meanDepthItem;
|
|
|
|
DiveGasPressureItem *gasPressureItem;
|
|
|
|
QList<DiveEventItem *> eventItems;
|
|
|
|
DiveTextItem *diveComputerText;
|
|
|
|
DiveReportedCeiling *reportedCeiling;
|
|
|
|
PartialPressureGasItem *pn2GasItem;
|
|
|
|
PartialPressureGasItem *pheGasItem;
|
|
|
|
PartialPressureGasItem *po2GasItem;
|
|
|
|
PartialPressureGasItem *o2SetpointGasItem;
|
|
|
|
PartialPressureGasItem *ccrsensor1GasItem;
|
|
|
|
PartialPressureGasItem *ccrsensor2GasItem;
|
|
|
|
PartialPressureGasItem *ccrsensor3GasItem;
|
|
|
|
PartialPressureGasItem *ocpo2GasItem;
|
|
|
|
DiveCalculatedCeiling *diveCeiling;
|
|
|
|
DiveTextItem *decoModelParameters;
|
2021-12-03 17:49:49 +00:00
|
|
|
std::vector<DiveCalculatedTissue *> allTissues;
|
2021-08-03 07:51:37 +00:00
|
|
|
DiveHeartrateItem *heartBeatItem;
|
2021-08-29 20:13:26 +00:00
|
|
|
DivePercentageItem *percentageItem;
|
2021-08-03 07:51:37 +00:00
|
|
|
TankItem *tankItem;
|
2021-08-30 19:11:11 +00:00
|
|
|
std::shared_ptr<const DivePixmaps> pixmaps;
|
2021-12-02 22:53:17 +00:00
|
|
|
std::unique_ptr<ProfileAnimation> animation;
|
|
|
|
std::vector<DiveCartesianAxis *> animatedAxes;
|
2021-06-05 16:42:56 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|