subsurface/profile-widget/ruleritem.h
Berthold Stoeger fbd74c26d6 Profile: Change RulerItem2 to use index instead of pointer
To make the pressure data dynamic (size of the arrays depending
on the cylinders in the dive), it has to be separated from the
standard plot_data structure. To enable this, use indexes instead
of pointers to plot_data elements. This commit converts
the RulerItem2 to use an index.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2019-11-09 19:19:04 +01:00

60 lines
1.3 KiB
C++

// SPDX-License-Identifier: GPL-2.0
#ifndef RULERITEM_H
#define RULERITEM_H
#include <QObject>
#include <QGraphicsEllipseItem>
#include <QGraphicsObject>
#include "profile-widget/divecartesianaxis.h"
#include "core/display.h"
struct plot_data;
class RulerItem2;
class RulerNodeItem2 : public QObject, public QGraphicsEllipseItem {
Q_OBJECT
friend class RulerItem2;
public:
explicit RulerNodeItem2();
void setRuler(RulerItem2 *r);
void setPlotInfo(const struct plot_info &info);
void recalculate();
protected:
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
private:
struct plot_info pInfo;
int idx;
RulerItem2 *ruler;
DiveCartesianAxis *timeAxis;
DiveCartesianAxis *depthAxis;
};
class RulerItem2 : public QObject, public QGraphicsLineItem {
Q_OBJECT
public:
explicit RulerItem2();
void recalculate();
void setPlotInfo(const struct plot_info &pInfo);
RulerNodeItem2 *sourceNode() const;
RulerNodeItem2 *destNode() const;
void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth);
void setVisible(bool visible);
public
slots:
void settingsChanged(bool toggled);
private:
struct plot_info pInfo;
QPointF startPoint, endPoint;
RulerNodeItem2 *source, *dest;
QString text;
DiveCartesianAxis *timeAxis;
DiveCartesianAxis *depthAxis;
QGraphicsRectItem *textItemBack;
QGraphicsSimpleTextItem *textItem;
};
#endif