mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Added a ruler which can be dragged along the profile
This patch adds a ruler QGraphicsItem which can be dragged along the profile. The ruler displays minimum, maximum and average for depth and speed (ascent/descent rate). Also, all used gas will be displayed. This also adds a new attribute to struct plot_data to store the speed (not just as velocity_t). Signed-off-by: Maximilian Güntner <maximilian.guentner@gmail.com>
This commit is contained in:
parent
3312c9a3a4
commit
248f1b86d1
5 changed files with 411 additions and 8 deletions
|
|
@ -57,6 +57,49 @@ private:
|
|||
QRectF nextRectangle;
|
||||
};
|
||||
|
||||
class RulerItem;
|
||||
|
||||
class RulerNodeItem : public QObject, public QGraphicsEllipseItem
|
||||
{
|
||||
Q_OBJECT
|
||||
friend class RulerItem;
|
||||
public:
|
||||
explicit RulerNodeItem(QGraphicsItem* parent, graphics_context gc);
|
||||
void setRuler(RulerItem *r);
|
||||
void recalculate();
|
||||
|
||||
protected:
|
||||
QVariant itemChange(GraphicsItemChange change, const QVariant & value );
|
||||
|
||||
private:
|
||||
graphics_context gc;
|
||||
struct plot_data *entry;
|
||||
RulerItem* ruler;
|
||||
};
|
||||
|
||||
class RulerItem : public QGraphicsObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit RulerItem(QGraphicsItem* parent,
|
||||
RulerNodeItem *sourceMarker,
|
||||
RulerNodeItem *destMarker);
|
||||
void recalculate();
|
||||
|
||||
RulerNodeItem* sourceNode() const;
|
||||
RulerNodeItem* destNode() const;
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget * widget = 0);
|
||||
QRectF boundingRect() const;
|
||||
QPainterPath shape() const;
|
||||
|
||||
private:
|
||||
QPointF startPoint, endPoint;
|
||||
RulerNodeItem *source, *dest;
|
||||
QString text;
|
||||
int height;
|
||||
int paint_direction;
|
||||
};
|
||||
|
||||
class EventItem : public QGraphicsPolygonItem
|
||||
{
|
||||
public:
|
||||
|
|
@ -128,6 +171,10 @@ private:
|
|||
void plot_pp_text();
|
||||
void plot_depth_scale();
|
||||
|
||||
void create_ruler();
|
||||
void add_ruler();
|
||||
void remove_ruler();
|
||||
|
||||
QColor getColor(const color_indice_t i);
|
||||
QColor get_sac_color(int sac, int avg_sac);
|
||||
void scrollViewTo(const QPoint pos);
|
||||
|
|
@ -139,6 +186,8 @@ private:
|
|||
struct dive *dive;
|
||||
struct divecomputer *diveDC;
|
||||
int zoomLevel;
|
||||
|
||||
bool rulerEnabled;
|
||||
bool printMode;
|
||||
bool isGrayscale;
|
||||
|
||||
|
|
@ -147,6 +196,7 @@ private:
|
|||
QGraphicsItem* timeMarkers;
|
||||
QGraphicsItem* depthMarkers;
|
||||
QGraphicsItem* diveComputer;
|
||||
RulerItem *rulerItem;
|
||||
|
||||
// For 'Plan' mode.:
|
||||
GraphicsTextEditor *depthEditor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue