2017-04-27 18:26:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-01-14 16:30:13 +00:00
|
|
|
#ifndef PROFILEWIDGET2_H
|
|
|
|
#define PROFILEWIDGET2_H
|
|
|
|
|
|
|
|
#include <QGraphicsView>
|
2018-04-06 15:58:16 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
2014-01-14 16:30:13 +00:00
|
|
|
|
|
|
|
// /* The idea of this widget is to display and edit the profile.
|
|
|
|
// * It has:
|
|
|
|
// * 1 - ToolTip / Legend item, displays every information of the current mouse position on it, plus the legends of the maps.
|
|
|
|
// * 2 - ToolBox, displays the QActions that are used to do special stuff on the profile ( like activating the plugins. )
|
|
|
|
// * 3 - Cartesian Axis for depth ( y )
|
|
|
|
// * 4 - Cartesian Axis for Gases ( y )
|
|
|
|
// * 5 - Cartesian Axis for Time ( x )
|
|
|
|
// *
|
|
|
|
// * It needs to be dynamic, things should *flow* on it, not just appear / disappear.
|
|
|
|
// */
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "profile-widget/divelineitem.h"
|
|
|
|
#include "profile-widget/diveprofileitem.h"
|
|
|
|
#include "core/display.h"
|
2018-01-10 16:28:24 +00:00
|
|
|
#include "core/color.h"
|
2018-06-30 09:36:37 +00:00
|
|
|
#include "core/units.h"
|
2014-01-16 17:02:32 +00:00
|
|
|
|
2014-02-27 18:20:03 +00:00
|
|
|
class RulerItem2;
|
2014-02-11 04:28:33 +00:00
|
|
|
struct dive;
|
|
|
|
struct plot_info;
|
2014-02-05 16:34:45 +00:00
|
|
|
class ToolTipItem;
|
2014-01-21 19:34:36 +00:00
|
|
|
class DiveReportedCeiling;
|
2014-01-21 12:48:26 +00:00
|
|
|
class DiveTextItem;
|
2014-01-16 20:39:13 +00:00
|
|
|
class TemperatureAxis;
|
2014-01-16 17:02:32 +00:00
|
|
|
class DiveEventItem;
|
2014-02-11 04:28:33 +00:00
|
|
|
class DivePlotDataModel;
|
|
|
|
class DivePixmapItem;
|
|
|
|
class DiveRectItem;
|
|
|
|
class DepthAxis;
|
|
|
|
class DiveCartesianAxis;
|
|
|
|
class DiveProfileItem;
|
|
|
|
class TimeAxis;
|
|
|
|
class DiveTemperatureItem;
|
2014-02-23 23:28:31 +00:00
|
|
|
class DiveHeartrateItem;
|
2014-02-11 04:28:33 +00:00
|
|
|
class DiveGasPressureItem;
|
|
|
|
class DiveCalculatedCeiling;
|
|
|
|
class DiveCalculatedTissue;
|
|
|
|
class PartialPressureGasItem;
|
|
|
|
class PartialGasPressureAxis;
|
|
|
|
class AbstractProfilePolygonItem;
|
2014-08-15 00:22:27 +00:00
|
|
|
class TankItem;
|
2014-05-22 00:18:10 +00:00
|
|
|
class DiveHandler;
|
|
|
|
class QGraphicsSimpleTextItem;
|
|
|
|
class QModelIndex;
|
2014-06-08 15:43:04 +00:00
|
|
|
class DivePictureItem;
|
2014-01-14 16:30:13 +00:00
|
|
|
|
|
|
|
class ProfileWidget2 : public QGraphicsView {
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
enum State {
|
|
|
|
EMPTY,
|
|
|
|
PROFILE,
|
|
|
|
EDIT,
|
|
|
|
ADD,
|
|
|
|
PLAN,
|
|
|
|
INVALID
|
|
|
|
};
|
|
|
|
enum Items {
|
|
|
|
BACKGROUND,
|
|
|
|
PROFILE_Y_AXIS,
|
|
|
|
GAS_Y_AXIS,
|
|
|
|
TIME_AXIS,
|
|
|
|
DEPTH_CONTROLLER,
|
|
|
|
TIME_CONTROLLER,
|
|
|
|
COLUMNS
|
|
|
|
};
|
2014-01-14 16:30:13 +00:00
|
|
|
|
2014-03-07 15:42:13 +00:00
|
|
|
ProfileWidget2(QWidget *parent = 0);
|
2019-07-15 18:41:42 +00:00
|
|
|
~ProfileWidget2();
|
2015-10-11 11:21:13 +00:00
|
|
|
void resetZoom();
|
2018-07-15 15:56:18 +00:00
|
|
|
void scale(qreal sx, qreal sy);
|
2019-07-10 20:47:53 +00:00
|
|
|
void plotDive(const struct dive *d = 0, bool force = false, bool clearPictures = false, bool instant = false);
|
2018-01-10 16:08:56 +00:00
|
|
|
void setupItem(AbstractProfilePolygonItem *item, DiveCartesianAxis *vAxis, int vData, int hData, int zValue);
|
2014-03-25 21:34:09 +00:00
|
|
|
void setPrintMode(bool mode, bool grayscale = false);
|
2014-07-09 20:09:52 +00:00
|
|
|
bool getPrintMode();
|
2014-05-22 18:40:22 +00:00
|
|
|
bool isPointOutOfBoundaries(const QPointF &point) const;
|
2014-05-26 22:17:34 +00:00
|
|
|
bool isPlanner();
|
2014-07-09 20:09:52 +00:00
|
|
|
double getFontPrintScale();
|
|
|
|
void setFontPrintScale(double scale);
|
2015-11-06 00:05:44 +00:00
|
|
|
#ifndef SUBSURFACE_MOBILE
|
2018-09-29 20:13:44 +00:00
|
|
|
bool eventFilter(QObject *, QEvent *) override;
|
2014-08-20 02:54:18 +00:00
|
|
|
void clearHandlers();
|
2015-11-06 00:05:44 +00:00
|
|
|
#endif
|
2015-01-31 18:32:02 +00:00
|
|
|
void setToolTipVisibile(bool visible);
|
2014-05-21 17:24:19 +00:00
|
|
|
State currentState;
|
2019-07-10 20:40:06 +00:00
|
|
|
int animSpeed;
|
2014-01-14 16:30:13 +00:00
|
|
|
|
2015-07-29 19:21:27 +00:00
|
|
|
signals:
|
|
|
|
void fontPrintScaleChanged(double scale);
|
2015-11-05 17:32:19 +00:00
|
|
|
void enableToolbar(bool enable);
|
2015-11-05 19:12:22 +00:00
|
|
|
void enableShortcuts();
|
|
|
|
void disableShortcuts(bool paste);
|
2019-03-29 17:29:08 +00:00
|
|
|
void updateDiveInfo();
|
2015-11-05 21:44:19 +00:00
|
|
|
void editCurrentDive();
|
2015-11-06 12:40:20 +00:00
|
|
|
void dateTimeChangedItems();
|
2015-07-29 19:21:27 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
public
|
|
|
|
slots: // Necessary to call from QAction's signals.
|
2015-11-06 12:40:20 +00:00
|
|
|
void dateTimeChanged();
|
2014-01-14 16:30:13 +00:00
|
|
|
void settingsChanged();
|
2016-01-25 17:54:23 +00:00
|
|
|
void actionRequestedReplot(bool triggered);
|
2014-02-07 18:34:42 +00:00
|
|
|
void setEmptyState();
|
|
|
|
void setProfileState();
|
2015-11-06 00:05:44 +00:00
|
|
|
void setReplot(bool state);
|
|
|
|
void replot(dive *d = 0);
|
|
|
|
#ifndef SUBSURFACE_MOBILE
|
2018-01-10 12:55:29 +00:00
|
|
|
void plotPictures();
|
2018-06-30 09:36:37 +00:00
|
|
|
void removePictures(const QVector<QString> &fileUrls);
|
2016-02-06 21:25:58 +00:00
|
|
|
void setPlanState();
|
|
|
|
void setAddState();
|
2014-05-22 00:18:10 +00:00
|
|
|
void pointInserted(const QModelIndex &parent, int start, int end);
|
|
|
|
void pointsRemoved(const QModelIndex &, int start, int end);
|
2018-07-15 15:56:18 +00:00
|
|
|
void updateThumbnail(QString filename, QImage thumbnail, duration_t duration);
|
2020-03-01 16:16:08 +00:00
|
|
|
void cylinderChanged(dive *d);
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2014-05-23 23:51:30 +00:00
|
|
|
/* this is called for every move on the handlers. maybe we can speed up this a bit? */
|
|
|
|
void recreatePlannedDive();
|
|
|
|
|
2014-05-24 15:39:40 +00:00
|
|
|
/* key press handlers */
|
|
|
|
void keyEscAction();
|
|
|
|
void keyDeleteAction();
|
|
|
|
void keyUpAction();
|
|
|
|
void keyDownAction();
|
|
|
|
void keyLeftAction();
|
|
|
|
void keyRightAction();
|
|
|
|
|
2014-06-30 22:08:16 +00:00
|
|
|
void divePlannerHandlerClicked();
|
|
|
|
void divePlannerHandlerReleased();
|
2015-11-06 00:05:44 +00:00
|
|
|
#endif
|
2015-01-02 00:28:37 +00:00
|
|
|
|
2014-01-14 16:30:13 +00:00
|
|
|
protected:
|
2018-09-29 20:13:44 +00:00
|
|
|
void resizeEvent(QResizeEvent *event) override;
|
2016-02-06 21:25:58 +00:00
|
|
|
#ifndef SUBSURFACE_MOBILE
|
2018-09-29 20:13:44 +00:00
|
|
|
void wheelEvent(QWheelEvent *event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
|
|
void contextMenuEvent(QContextMenuEvent *event) override;
|
|
|
|
void mouseDoubleClickEvent(QMouseEvent *event) override;
|
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
2016-02-06 21:25:58 +00:00
|
|
|
#endif
|
2018-09-29 20:13:44 +00:00
|
|
|
void dropEvent(QDropEvent *event) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent *event) override;
|
|
|
|
void dragMoveEvent(QDragMoveEvent *event) override;
|
2015-11-03 20:17:50 +00:00
|
|
|
|
2020-01-30 14:37:46 +00:00
|
|
|
private:
|
2020-01-30 14:03:48 +00:00
|
|
|
void changeGas(int tank, int seconds);
|
2014-02-07 17:32:39 +00:00
|
|
|
void fixBackgroundPos();
|
2014-02-28 04:09:57 +00:00
|
|
|
void scrollViewTo(const QPoint &pos);
|
2014-02-07 17:32:39 +00:00
|
|
|
void setupSceneAndFlags();
|
|
|
|
void setupItemSizes();
|
|
|
|
void addItemsToScene();
|
|
|
|
void setupItemOnScene();
|
2014-05-22 00:23:19 +00:00
|
|
|
void disconnectTemporaryConnections();
|
2014-11-19 22:31:28 +00:00
|
|
|
struct plot_data *getEntryFromPos(QPointF pos);
|
2018-01-10 15:50:57 +00:00
|
|
|
void addActionShortcut(const Qt::Key shortcut, void (ProfileWidget2::*slot)());
|
2018-01-10 16:33:20 +00:00
|
|
|
void createPPGas(PartialPressureGasItem *item, int verticalColumn, color_index_t color, color_index_t colorAlert,
|
2018-09-02 20:26:19 +00:00
|
|
|
const double *thresholdSettingsMin, const double *thresholdSettingsMax);
|
2018-04-06 15:58:16 +00:00
|
|
|
void clearPictures();
|
2019-02-03 12:28:33 +00:00
|
|
|
void plotPicturesInternal(const struct dive *d, bool synchronous);
|
2020-03-02 20:48:53 +00:00
|
|
|
void addDivemodeSwitch(int seconds, int divemode);
|
2020-03-02 21:02:33 +00:00
|
|
|
void addBookmark(int seconds);
|
|
|
|
void splitDive(int seconds);
|
|
|
|
void addSetpointChange(int seconds);
|
2020-03-02 21:23:40 +00:00
|
|
|
void removeEvent(DiveEventItem *item);
|
|
|
|
void hideEvents(DiveEventItem *item);
|
|
|
|
void editName(DiveEventItem *item);
|
2020-03-02 21:48:12 +00:00
|
|
|
void unhideEvents();
|
|
|
|
void makeFirstDC();
|
|
|
|
void deleteCurrentDC();
|
|
|
|
void splitCurrentDC();
|
2014-01-15 14:00:23 +00:00
|
|
|
private:
|
|
|
|
DivePlotDataModel *dataModel;
|
2014-02-04 23:47:50 +00:00
|
|
|
int zoomLevel;
|
2014-03-10 15:59:02 +00:00
|
|
|
qreal zoomFactor;
|
2014-02-07 18:34:42 +00:00
|
|
|
DivePixmapItem *background;
|
|
|
|
QString backgroundFile;
|
2016-02-06 21:25:58 +00:00
|
|
|
#ifndef SUBSURFACE_MOBILE
|
2014-02-05 16:34:45 +00:00
|
|
|
ToolTipItem *toolTipItem;
|
2016-02-06 21:25:58 +00:00
|
|
|
#endif
|
2014-02-27 15:39:53 +00:00
|
|
|
bool isPlotZoomed;
|
2014-12-13 21:06:52 +00:00
|
|
|
bool replotEnabled;
|
2014-01-16 17:02:32 +00:00
|
|
|
// 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.
|
2014-11-19 22:28:16 +00:00
|
|
|
struct plot_info plotInfo;
|
2014-02-09 18:11:17 +00:00
|
|
|
DepthAxis *profileYAxis;
|
2014-01-27 17:14:42 +00:00
|
|
|
PartialGasPressureAxis *gasYAxis;
|
2014-01-16 20:39:13 +00:00
|
|
|
TemperatureAxis *temperatureAxis;
|
2014-01-15 14:00:23 +00:00
|
|
|
TimeAxis *timeAxis;
|
|
|
|
DiveProfileItem *diveProfileItem;
|
2014-01-16 20:39:13 +00:00
|
|
|
DiveTemperatureItem *temperatureItem;
|
2015-01-02 00:28:37 +00:00
|
|
|
DiveMeanDepthItem *meanDepthItem;
|
2014-01-17 16:28:59 +00:00
|
|
|
DiveCartesianAxis *cylinderPressureAxis;
|
2014-01-17 17:34:15 +00:00
|
|
|
DiveGasPressureItem *gasPressureItem;
|
2014-02-28 04:09:57 +00:00
|
|
|
QList<DiveEventItem *> eventItems;
|
2014-01-21 12:48:26 +00:00
|
|
|
DiveTextItem *diveComputerText;
|
2016-02-06 21:25:58 +00:00
|
|
|
DiveReportedCeiling *reportedCeiling;
|
2014-01-23 19:54:34 +00:00
|
|
|
PartialPressureGasItem *pn2GasItem;
|
2014-01-23 19:59:14 +00:00
|
|
|
PartialPressureGasItem *pheGasItem;
|
2014-01-23 20:03:28 +00:00
|
|
|
PartialPressureGasItem *po2GasItem;
|
2015-01-05 07:20:26 +00:00
|
|
|
PartialPressureGasItem *o2SetpointGasItem;
|
2015-01-20 18:13:53 +00:00
|
|
|
PartialPressureGasItem *ccrsensor1GasItem;
|
|
|
|
PartialPressureGasItem *ccrsensor2GasItem;
|
|
|
|
PartialPressureGasItem *ccrsensor3GasItem;
|
2018-03-14 15:13:37 +00:00
|
|
|
PartialPressureGasItem *ocpo2GasItem;
|
2017-03-25 12:03:37 +00:00
|
|
|
#ifndef SUBSURFACE_MOBILE
|
|
|
|
DiveCalculatedCeiling *diveCeiling;
|
|
|
|
DiveTextItem *decoModelParameters;
|
|
|
|
QList<DiveCalculatedTissue *> allTissues;
|
2014-02-20 01:18:26 +00:00
|
|
|
DiveCartesianAxis *heartBeatAxis;
|
2014-02-23 23:28:31 +00:00
|
|
|
DiveHeartrateItem *heartBeatItem;
|
2014-09-15 12:09:00 +00:00
|
|
|
DiveCartesianAxis *percentageAxis;
|
|
|
|
QList<DivePercentageItem *> allPercentages;
|
|
|
|
DiveAmbPressureItem *ambPressureItem;
|
|
|
|
DiveGFLineItem *gflineItem;
|
2014-08-05 21:27:00 +00:00
|
|
|
DiveLineItem *mouseFollowerVertical;
|
|
|
|
DiveLineItem *mouseFollowerHorizontal;
|
2014-02-27 18:20:03 +00:00
|
|
|
RulerItem2 *rulerItem;
|
2016-02-06 21:25:58 +00:00
|
|
|
#endif
|
2014-08-15 00:22:27 +00:00
|
|
|
TankItem *tankItem;
|
2014-03-25 21:34:09 +00:00
|
|
|
bool isGrayscale;
|
|
|
|
bool printMode;
|
2014-05-22 00:18:10 +00:00
|
|
|
|
|
|
|
QList<QGraphicsSimpleTextItem *> gases;
|
2018-04-06 15:58:16 +00:00
|
|
|
|
2018-04-09 17:58:58 +00:00
|
|
|
//specifics for ADD and PLAN
|
|
|
|
#ifndef SUBSURFACE_MOBILE
|
2018-06-30 09:36:37 +00:00
|
|
|
// The list of pictures in this plot. The pictures are sorted by offset in seconds.
|
|
|
|
// For the same offset, sort by filename.
|
|
|
|
// Pictures that are outside of the dive time are not shown.
|
|
|
|
struct PictureEntry {
|
|
|
|
offset_t offset;
|
2018-07-15 15:56:18 +00:00
|
|
|
duration_t duration;
|
2018-06-30 09:36:37 +00:00
|
|
|
QString filename;
|
|
|
|
std::unique_ptr<DivePictureItem> thumbnail;
|
2018-07-15 15:56:18 +00:00
|
|
|
// For videos with known duration, we represent the duration of the video by a line
|
|
|
|
std::unique_ptr<QGraphicsRectItem> durationLine;
|
2019-02-02 20:23:52 +00:00
|
|
|
PictureEntry (offset_t offsetIn, const QString &filenameIn, QGraphicsScene *scene, bool synchronous);
|
2018-06-30 09:36:37 +00:00
|
|
|
bool operator< (const PictureEntry &e) const;
|
|
|
|
};
|
2018-06-30 19:32:14 +00:00
|
|
|
void updateThumbnailXPos(PictureEntry &e);
|
2018-06-30 09:36:37 +00:00
|
|
|
std::vector<PictureEntry> pictures;
|
2018-06-30 10:55:55 +00:00
|
|
|
void calculatePictureYPositions();
|
2018-07-15 15:56:18 +00:00
|
|
|
void updateDurationLine(PictureEntry &e);
|
|
|
|
void updateThumbnailPaintOrder();
|
2015-11-06 00:05:44 +00:00
|
|
|
|
|
|
|
QList<DiveHandler *> handles;
|
2014-05-22 02:31:26 +00:00
|
|
|
void repositionDiveHandlers();
|
2014-05-24 01:22:02 +00:00
|
|
|
int fixHandlerIndex(DiveHandler *activeHandler);
|
2014-05-24 01:39:51 +00:00
|
|
|
friend class DiveHandler;
|
2015-11-06 00:05:44 +00:00
|
|
|
#endif
|
2014-05-24 15:39:40 +00:00
|
|
|
QHash<Qt::Key, QAction *> actionsForKeys;
|
2014-05-26 20:51:46 +00:00
|
|
|
bool shouldCalculateMaxTime;
|
2014-06-30 22:08:16 +00:00
|
|
|
bool shouldCalculateMaxDepth;
|
2014-05-26 20:51:46 +00:00
|
|
|
int maxtime;
|
2014-06-30 22:08:16 +00:00
|
|
|
int maxdepth;
|
2014-07-09 20:09:52 +00:00
|
|
|
double fontPrintScale;
|
2014-01-14 16:30:13 +00:00
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // PROFILEWIDGET2_H
|