2017-04-27 18:26:36 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2014-01-14 18:20:15 +00:00
|
|
|
#ifndef DIVECARTESIANAXIS_H
|
|
|
|
#define DIVECARTESIANAXIS_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QGraphicsLineItem>
|
2016-04-05 05:02:03 +00:00
|
|
|
#include "core/color.h"
|
2021-06-28 18:29:46 +00:00
|
|
|
#include "core/units.h"
|
2014-01-22 19:10:18 +00:00
|
|
|
|
2021-06-28 18:29:46 +00:00
|
|
|
class ProfileScene;
|
2014-01-22 19:10:18 +00:00
|
|
|
class QPropertyAnimation;
|
2014-01-14 18:20:15 +00:00
|
|
|
class DiveTextItem;
|
|
|
|
class DiveLineItem;
|
2014-01-27 17:14:42 +00:00
|
|
|
class DivePlotDataModel;
|
2014-01-14 18:20:15 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class DiveCartesianAxis : public QObject, public QGraphicsLineItem {
|
2014-01-14 18:20:15 +00:00
|
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY(QLineF line WRITE setLine READ line)
|
|
|
|
Q_PROPERTY(QPointF pos WRITE setPos READ pos)
|
|
|
|
Q_PROPERTY(qreal x WRITE setX READ x)
|
|
|
|
Q_PROPERTY(qreal y WRITE setY READ y)
|
2015-10-11 11:21:14 +00:00
|
|
|
private:
|
|
|
|
bool printMode;
|
2020-12-20 12:01:21 +00:00
|
|
|
QPen gridPen() const;
|
2014-01-14 18:20:15 +00:00
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
enum Orientation {
|
|
|
|
TopToBottom,
|
|
|
|
BottomToTop,
|
|
|
|
LeftToRight,
|
|
|
|
RightToLeft
|
|
|
|
};
|
2021-08-09 14:48:08 +00:00
|
|
|
DiveCartesianAxis(double dpr, bool printMode, ProfileScene &scene);
|
2018-07-31 05:41:19 +00:00
|
|
|
~DiveCartesianAxis();
|
2014-01-14 18:20:15 +00:00
|
|
|
void setMinimum(double minimum);
|
|
|
|
void setMaximum(double maximum);
|
|
|
|
void setTickInterval(double interval);
|
2014-01-16 21:28:33 +00:00
|
|
|
void setOrientation(Orientation orientation);
|
2014-01-14 18:20:15 +00:00
|
|
|
void setTickSize(qreal size);
|
2014-02-15 19:15:57 +00:00
|
|
|
void setFontLabelScale(qreal scale);
|
2014-01-14 18:20:15 +00:00
|
|
|
double minimum() const;
|
|
|
|
double maximum() const;
|
2014-02-28 04:09:57 +00:00
|
|
|
qreal valueAt(const QPointF &p) const;
|
2020-12-20 12:01:21 +00:00
|
|
|
qreal posAtValue(qreal value) const;
|
2014-02-28 04:09:57 +00:00
|
|
|
void setColor(const QColor &color);
|
|
|
|
void setTextColor(const QColor &color);
|
2021-08-03 08:32:08 +00:00
|
|
|
void animateChangeLine(const QLineF &newLine, int animSpeed);
|
2014-02-12 16:24:19 +00:00
|
|
|
void setTextVisible(bool arg1);
|
2014-02-16 00:54:41 +00:00
|
|
|
void setLinesVisible(bool arg1);
|
2014-02-15 23:55:31 +00:00
|
|
|
void setLineSize(qreal lineSize);
|
2014-07-29 21:48:17 +00:00
|
|
|
void setLine(const QLineF& line);
|
2021-08-03 08:32:08 +00:00
|
|
|
virtual void updateTicks(int animSpeed, color_index_t color = TIME_GRID);
|
2021-08-28 12:25:04 +00:00
|
|
|
double width() const; // only for vertical axes
|
|
|
|
double height() const; // only for horizontal axes
|
2014-02-12 16:24:19 +00:00
|
|
|
|
2014-01-16 14:32:45 +00:00
|
|
|
signals:
|
|
|
|
void sizeChanged();
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2014-01-14 18:20:15 +00:00
|
|
|
protected:
|
2021-06-28 18:29:46 +00:00
|
|
|
ProfileScene &scene;
|
2020-12-20 12:01:21 +00:00
|
|
|
virtual QString textForValue(double value) const;
|
|
|
|
virtual QColor colorForValue(double value) const;
|
2021-08-11 08:57:42 +00:00
|
|
|
double textWidth(const QString &s) const;
|
2014-01-16 21:28:33 +00:00
|
|
|
Orientation orientation;
|
2014-02-28 04:09:57 +00:00
|
|
|
QList<DiveTextItem *> labels;
|
|
|
|
QList<DiveLineItem *> lines;
|
2014-01-14 18:20:15 +00:00
|
|
|
double min;
|
|
|
|
double max;
|
|
|
|
double interval;
|
2014-02-07 19:59:21 +00:00
|
|
|
double tick_size;
|
2014-01-14 18:20:15 +00:00
|
|
|
QColor textColor;
|
2014-02-12 16:24:19 +00:00
|
|
|
bool textVisibility;
|
2014-02-16 00:54:41 +00:00
|
|
|
bool lineVisibility;
|
2014-02-15 19:15:57 +00:00
|
|
|
double labelScale;
|
2014-02-15 23:55:31 +00:00
|
|
|
qreal line_size;
|
2014-05-26 21:01:38 +00:00
|
|
|
bool changed;
|
2021-08-09 14:48:08 +00:00
|
|
|
double dpr;
|
2014-01-14 18:20:15 +00:00
|
|
|
};
|
|
|
|
|
2014-01-15 12:54:33 +00:00
|
|
|
class DepthAxis : public DiveCartesianAxis {
|
2014-01-22 19:10:18 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-08-09 14:48:08 +00:00
|
|
|
DepthAxis(double dpr, bool printMode, ProfileScene &scene);
|
2020-04-13 17:41:30 +00:00
|
|
|
private:
|
2020-12-20 12:01:21 +00:00
|
|
|
QString textForValue(double value) const override;
|
|
|
|
QColor colorForValue(double value) const override;
|
2014-01-15 12:54:33 +00:00
|
|
|
};
|
|
|
|
|
2014-01-15 13:08:31 +00:00
|
|
|
class TimeAxis : public DiveCartesianAxis {
|
2014-01-27 19:18:35 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-06-02 09:24:14 +00:00
|
|
|
using DiveCartesianAxis::DiveCartesianAxis;
|
2021-08-03 08:32:08 +00:00
|
|
|
void updateTicks(int animSpeed, color_index_t color = TIME_GRID) override;
|
2020-04-13 17:41:30 +00:00
|
|
|
private:
|
2020-12-20 12:01:21 +00:00
|
|
|
QString textForValue(double value) const override;
|
|
|
|
QColor colorForValue(double value) const override;
|
2014-01-16 20:39:13 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class TemperatureAxis : public DiveCartesianAxis {
|
2014-01-16 20:39:13 +00:00
|
|
|
Q_OBJECT
|
2015-11-06 11:54:35 +00:00
|
|
|
public:
|
2021-06-02 09:24:14 +00:00
|
|
|
using DiveCartesianAxis::DiveCartesianAxis;
|
2020-04-13 17:41:30 +00:00
|
|
|
private:
|
2020-12-20 12:01:21 +00:00
|
|
|
QString textForValue(double value) const override;
|
2014-01-15 13:08:31 +00:00
|
|
|
};
|
2014-01-16 14:32:45 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class PartialGasPressureAxis : public DiveCartesianAxis {
|
2014-01-27 17:14:42 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2021-08-09 14:48:08 +00:00
|
|
|
PartialGasPressureAxis(const DivePlotDataModel &model, double dpr, bool printMode, ProfileScene &scene);
|
2021-08-03 08:32:08 +00:00
|
|
|
void update(int animSpeed);
|
2021-08-11 08:57:42 +00:00
|
|
|
double width() const;
|
2014-01-27 17:14:42 +00:00
|
|
|
private:
|
2020-12-29 21:49:40 +00:00
|
|
|
const DivePlotDataModel &model;
|
2014-01-27 17:14:42 +00:00
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // DIVECARTESIANAXIS_H
|