mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
ed83f6ce32
Now this one was strange: The ruler items keep a copy of the plot_info struct. However, only a shallow copy is made (the actual plot data is not copied). This means that the data is only valid as long as the source plot_info is valid. But if that is guaranteed, we simply can keep a pointer instead of the full object. I wonder if it wouldn't be better still to keep a pointer to the profile and query that for the plot info? Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
60 lines
1.4 KiB
C++
60 lines
1.4 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"
|
|
|
|
struct plot_data;
|
|
struct plot_info;
|
|
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();
|
|
|
|
private:
|
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
|
|
const 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 dive *d, 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:
|
|
const struct dive *dive;
|
|
const struct plot_info *pInfo;
|
|
QPointF startPoint, endPoint;
|
|
RulerNodeItem2 *source, *dest;
|
|
QString text;
|
|
DiveCartesianAxis *timeAxis;
|
|
DiveCartesianAxis *depthAxis;
|
|
QGraphicsRectItem *textItemBack;
|
|
QGraphicsSimpleTextItem *textItem;
|
|
};
|
|
#endif
|