2013-05-04 19:12:43 +00:00
|
|
|
#ifndef PROFILEGRAPHICS_H
|
|
|
|
#define PROFILEGRAPHICS_H
|
|
|
|
|
2013-07-13 15:18:26 +00:00
|
|
|
#include "graphicsview-common.h"
|
2013-05-08 21:56:06 +00:00
|
|
|
#include "../display.h"
|
2013-05-04 19:12:43 +00:00
|
|
|
#include <QGraphicsView>
|
2013-05-07 18:44:54 +00:00
|
|
|
#include <QGraphicsItem>
|
|
|
|
#include <QIcon>
|
2013-06-10 22:02:06 +00:00
|
|
|
#include <QDoubleSpinBox>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <QGraphicsProxyWidget>
|
2013-05-04 19:12:43 +00:00
|
|
|
|
2013-05-06 18:35:17 +00:00
|
|
|
struct graphics_context;
|
|
|
|
struct plot_info;
|
2013-09-25 00:07:07 +00:00
|
|
|
class RulerItem;
|
2014-02-05 16:25:28 +00:00
|
|
|
class ToolTipItem;
|
2013-09-25 00:07:07 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class RulerNodeItem : public QObject, public QGraphicsEllipseItem {
|
2013-09-25 00:07:07 +00:00
|
|
|
Q_OBJECT
|
|
|
|
friend class RulerItem;
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-09-25 00:07:07 +00:00
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit RulerNodeItem(QGraphicsItem *parent, graphics_context gc);
|
2013-09-25 00:07:07 +00:00
|
|
|
void setRuler(RulerItem *r);
|
|
|
|
void recalculate();
|
|
|
|
|
|
|
|
protected:
|
2014-02-28 04:09:57 +00:00
|
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
2013-09-25 00:07:07 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
graphics_context gc;
|
|
|
|
struct plot_data *entry;
|
2014-02-28 04:09:57 +00:00
|
|
|
RulerItem *ruler;
|
2013-09-25 00:07:07 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class RulerItem : public QGraphicsObject {
|
2013-09-25 00:07:07 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit RulerItem(QGraphicsItem *parent,
|
2013-09-25 00:07:07 +00:00
|
|
|
RulerNodeItem *sourceMarker,
|
|
|
|
RulerNodeItem *destMarker);
|
|
|
|
void recalculate();
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
RulerNodeItem *sourceNode() const;
|
|
|
|
RulerNodeItem *destNode() const;
|
|
|
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
|
2013-09-25 00:07:07 +00:00
|
|
|
QRectF boundingRect() const;
|
|
|
|
QPainterPath shape() const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
QPointF startPoint, endPoint;
|
|
|
|
RulerNodeItem *source, *dest;
|
|
|
|
QString text;
|
|
|
|
int height;
|
|
|
|
int paint_direction;
|
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class EventItem : public QGraphicsPixmapItem {
|
2013-05-07 23:09:51 +00:00
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
explicit EventItem(struct event *ev, QGraphicsItem *parent = 0, bool grayscale = false);
|
|
|
|
struct event *ev;
|
2013-05-07 23:09:51 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QString text;
|
2013-07-13 15:18:26 +00:00
|
|
|
bool isGrayscale;
|
|
|
|
|
|
|
|
QColor getColor(const color_indice_t i);
|
2013-05-07 23:09:51 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class GraphicsTextEditor : public QGraphicsTextItem {
|
2013-06-10 22:02:06 +00:00
|
|
|
Q_OBJECT
|
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
GraphicsTextEditor(QGraphicsItem *parent = 0);
|
2013-06-10 22:02:06 +00:00
|
|
|
|
|
|
|
protected:
|
2014-02-28 04:09:57 +00:00
|
|
|
virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
|
|
|
|
virtual void keyReleaseEvent(QKeyEvent *event);
|
2013-06-10 22:02:06 +00:00
|
|
|
|
|
|
|
signals:
|
2014-02-28 04:09:57 +00:00
|
|
|
void textChanged(const QString &text);
|
|
|
|
void editingFinished(const QString &text);
|
2013-06-10 22:02:06 +00:00
|
|
|
};
|
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
class ProfileGraphicsView : public QGraphicsView {
|
|
|
|
Q_OBJECT
|
2013-05-04 19:12:43 +00:00
|
|
|
public:
|
2014-02-28 04:09:57 +00:00
|
|
|
enum Mode {
|
|
|
|
DIVE,
|
|
|
|
PLAN
|
|
|
|
};
|
2013-06-10 20:33:46 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
ProfileGraphicsView(QWidget *parent = 0);
|
2014-01-15 08:30:42 +00:00
|
|
|
void plot(struct dive *d, bool forceRedraw = false);
|
2014-02-28 04:09:57 +00:00
|
|
|
bool eventFilter(QObject *obj, QEvent *event);
|
2013-05-16 19:00:33 +00:00
|
|
|
void clear();
|
2014-01-15 08:30:42 +00:00
|
|
|
void setPrintMode(bool mode, bool grayscale = false);
|
2013-05-04 19:12:43 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *event);
|
2014-02-28 04:09:57 +00:00
|
|
|
void mouseMoveEvent(QMouseEvent *event);
|
|
|
|
void wheelEvent(QWheelEvent *event);
|
|
|
|
void showEvent(QShowEvent *event);
|
|
|
|
void contextMenuEvent(QContextMenuEvent *event);
|
2013-05-04 19:12:43 +00:00
|
|
|
|
2014-02-28 04:09:57 +00:00
|
|
|
public
|
|
|
|
slots:
|
2013-05-26 18:33:45 +00:00
|
|
|
void refresh();
|
2014-02-28 04:09:57 +00:00
|
|
|
void edit_dive_time(const QString &time);
|
2013-09-25 00:39:21 +00:00
|
|
|
void on_rulerAction();
|
|
|
|
void on_scaleAction();
|
2013-11-20 01:03:18 +00:00
|
|
|
void changeGas();
|
|
|
|
void hideEvents();
|
2013-12-18 21:55:53 +00:00
|
|
|
void unhideEvents();
|
2013-11-20 01:03:18 +00:00
|
|
|
void removeEvent();
|
|
|
|
void addBookmark();
|
2014-02-28 04:09:57 +00:00
|
|
|
|
2013-05-04 22:20:49 +00:00
|
|
|
private:
|
2013-05-08 21:56:06 +00:00
|
|
|
void plot_depth_profile();
|
2014-02-28 04:09:57 +00:00
|
|
|
QGraphicsItemGroup *plot_text(text_render_options_t *tro, const QPointF &pos, const QString &text, QGraphicsItem *parent = 0);
|
2013-05-08 21:56:06 +00:00
|
|
|
void plot_events(struct divecomputer *dc);
|
|
|
|
void plot_one_event(struct event *event);
|
|
|
|
void plot_temperature_profile();
|
2013-10-11 16:52:38 +00:00
|
|
|
void plot_cylinder_pressure();
|
2013-05-09 18:28:50 +00:00
|
|
|
void plot_temperature_text();
|
|
|
|
void plot_single_temp_text(int sec, int mkelvin);
|
2013-05-09 18:37:43 +00:00
|
|
|
void plot_depth_text();
|
|
|
|
void plot_text_samples();
|
2014-02-28 04:09:57 +00:00
|
|
|
void plot_depth_sample(plot_data *entry, text_render_options_t *tro);
|
2013-05-09 18:42:38 +00:00
|
|
|
void plot_cylinder_pressure_text();
|
2013-05-10 15:56:56 +00:00
|
|
|
void plot_pressure_value(int mbar, int sec, double xalign, double yalign);
|
2013-05-31 06:21:39 +00:00
|
|
|
void plot_gas_value(int mbar, int sec, double xalign, double yalign, int o2, int he);
|
2013-05-09 18:47:39 +00:00
|
|
|
void plot_deco_text();
|
2013-06-13 17:52:30 +00:00
|
|
|
void plot_add_line(int sec, double val, QColor c, QPointF &from);
|
2013-05-09 18:47:39 +00:00
|
|
|
void plot_pp_gas_profile();
|
2013-05-09 20:30:16 +00:00
|
|
|
void plot_pp_text();
|
2013-05-09 21:02:52 +00:00
|
|
|
void plot_depth_scale();
|
|
|
|
|
2013-09-25 00:39:21 +00:00
|
|
|
|
2013-11-01 13:33:39 +00:00
|
|
|
void addControlItems(struct dive *d);
|
2013-09-25 00:39:21 +00:00
|
|
|
|
2013-09-25 00:07:07 +00:00
|
|
|
void create_ruler();
|
|
|
|
void add_ruler();
|
|
|
|
void remove_ruler();
|
|
|
|
|
2013-07-13 15:18:26 +00:00
|
|
|
QColor getColor(const color_indice_t i);
|
2013-05-09 03:24:03 +00:00
|
|
|
QColor get_sac_color(int sac, int avg_sac);
|
2013-07-04 20:55:27 +00:00
|
|
|
void scrollViewTo(const QPoint pos);
|
2014-02-28 04:09:57 +00:00
|
|
|
void createPPLegend(QString tr, const QColor &c, QPointF &legendPos);
|
2013-05-04 23:18:16 +00:00
|
|
|
|
|
|
|
QPen defaultPen;
|
|
|
|
QBrush defaultBrush;
|
2013-05-07 18:44:54 +00:00
|
|
|
ToolTipItem *toolTip;
|
2013-05-08 21:56:06 +00:00
|
|
|
graphics_context gc;
|
2014-01-07 03:57:20 +00:00
|
|
|
int diveId;
|
2013-05-23 03:31:27 +00:00
|
|
|
struct divecomputer *diveDC;
|
2013-05-10 14:45:07 +00:00
|
|
|
int zoomLevel;
|
2013-09-25 00:07:07 +00:00
|
|
|
|
|
|
|
bool rulerEnabled;
|
2013-07-12 14:20:59 +00:00
|
|
|
bool printMode;
|
2013-07-13 14:02:06 +00:00
|
|
|
bool isGrayscale;
|
2013-05-10 16:57:36 +00:00
|
|
|
|
|
|
|
// Top Level Items.
|
2014-02-28 04:09:57 +00:00
|
|
|
QGraphicsItem *profileGrid;
|
|
|
|
QGraphicsItem *timeMarkers;
|
|
|
|
QGraphicsItem *depthMarkers;
|
|
|
|
QGraphicsItem *diveComputer;
|
2013-09-25 00:07:07 +00:00
|
|
|
RulerItem *rulerItem;
|
2013-09-25 00:39:21 +00:00
|
|
|
QGraphicsProxyWidget *toolBarProxy;
|
2013-06-10 20:33:46 +00:00
|
|
|
|
2013-06-10 22:02:06 +00:00
|
|
|
// For 'Plan' mode.:
|
|
|
|
GraphicsTextEditor *depthEditor;
|
|
|
|
GraphicsTextEditor *timeEditor;
|
|
|
|
|
2013-06-10 20:33:46 +00:00
|
|
|
enum Mode mode;
|
2013-05-04 19:12:43 +00:00
|
|
|
};
|
|
|
|
|
2014-02-11 18:14:46 +00:00
|
|
|
#endif // PROFILEGRAPHICS_H
|