mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 21:20:19 +00:00
f2bfc72648
A couple of problems with the ruler: - the rotated text doesn't look very well at all and interpolation doesn't help it much - measuring towards the right most part of the profile makes the text go out of the screen To solve these issues and attempt to improve the ruler this patch does the following: - place the text at the bottom of the lowest of the start and end points. this way the line will never intersect with the text - clamp the x position, so that the text doesn't ever leave the screen horizontally - place a white background behind the text so that it will cover text and graphics under the ruler item (TODO: place the ruler on top of everything else) Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
56 lines
1.2 KiB
C++
56 lines
1.2 KiB
C++
#ifndef RULERITEM_H
|
|
#define RULERITEM_H
|
|
|
|
#include <QObject>
|
|
#include <QGraphicsEllipseItem>
|
|
#include <QGraphicsObject>
|
|
#include "divecartesianaxis.h"
|
|
#include "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(struct plot_info& info);
|
|
void recalculate();
|
|
|
|
protected:
|
|
QVariant itemChange(GraphicsItemChange change, const QVariant &value);
|
|
|
|
private:
|
|
struct plot_info pInfo;
|
|
struct plot_data *entry;
|
|
RulerItem2 *ruler;
|
|
DiveCartesianAxis *timeAxis;
|
|
DiveCartesianAxis *depthAxis;
|
|
};
|
|
|
|
class RulerItem2 : public QGraphicsLineItem {
|
|
public:
|
|
explicit RulerItem2();
|
|
void recalculate();
|
|
|
|
void setPlotInfo(struct plot_info pInfo);
|
|
RulerNodeItem2 *sourceNode() const;
|
|
RulerNodeItem2 *destNode() const;
|
|
void setAxis(DiveCartesianAxis *time, DiveCartesianAxis *depth);
|
|
|
|
private:
|
|
struct plot_info pInfo;
|
|
QPointF startPoint, endPoint;
|
|
RulerNodeItem2 *source, *dest;
|
|
QString text;
|
|
int height;
|
|
int paint_direction;
|
|
DiveCartesianAxis *timeAxis;
|
|
DiveCartesianAxis *depthAxis;
|
|
QGraphicsRectItem *textItemBack;
|
|
QGraphicsSimpleTextItem *textItem;
|
|
};
|
|
#endif
|