Use new GUI icons that fit the recent platform styles.
[GPXSee.git] / src / GUI / graphview.h
blob21ac3ecd8c49a27d7e3e3445e08688fcd7d50504
1 #ifndef GRAPHVIEW_H
2 #define GRAPHVIEW_H
4 #include <QGraphicsView>
5 #include <QList>
6 #include "data/graph.h"
7 #include "palette.h"
8 #include "units.h"
9 #include "infoitem.h"
12 class AxisItem;
13 class AxisLabelItem;
14 class SliderItem;
15 class SliderInfoItem;
16 class GraphItem;
17 class PathItem;
18 class GridItem;
19 class QGraphicsSimpleTextItem;
20 class GraphicsScene;
21 class QGestureEvent;
22 class QPinchGesture;
24 class GraphView : public QGraphicsView
26 Q_OBJECT
28 public:
29 GraphView(QWidget *parent = 0);
30 ~GraphView();
32 bool isEmpty() const {return _graphs.isEmpty();}
33 const QList<KV<QString, QString> > &info() const {return _info->info();}
34 void clear();
36 void plot(QPainter *painter, const QRectF &target, qreal scale);
38 void setPalette(const Palette &palette);
39 void setGraphWidth(int width);
40 void showGrid(bool show);
41 void showSliderInfo(bool show);
42 void useOpenGL(bool use);
43 void useAntiAliasing(bool use);
45 void setSliderPosition(qreal pos);
46 void setSliderColor(const QColor &color);
48 qreal sliderPosition() const {return _sliderPos;}
50 signals:
51 void sliderPositionChanged(qreal);
53 protected:
54 void addGraph(GraphItem *graph);
55 void removeGraph(GraphItem *graph);
56 void setGraphType(GraphType type);
57 void setUnits(Units units);
59 void resizeEvent(QResizeEvent *e);
60 void mousePressEvent(QMouseEvent *e);
61 void wheelEvent(QWheelEvent *e);
62 void changeEvent(QEvent *e);
63 void paintEvent(QPaintEvent *e);
64 bool event(QEvent *event);
66 const QString &yLabel() const {return _yLabel;}
67 const QString &yUnits() const {return _yUnits;}
68 qreal yScale() const {return _yScale;}
69 qreal yOffset() const {return _yOffset;}
70 void setYLabel(const QString &label);
71 void setYUnits(const QString &units);
72 void setYScale(qreal scale) {_yScale = scale;}
73 void setYOffset(qreal offset) {_yOffset = offset;}
75 void setSliderPrecision(int precision) {_precision = precision;}
76 void setMinYRange(qreal range) {_minYRange = range;}
78 QRectF bounds() const;
79 void redraw();
80 void addInfo(const QString &key, const QString &value);
81 void clearInfo();
83 GraphType _graphType;
84 Units _units;
85 Palette _palette;
86 int _width;
88 private slots:
89 void emitSliderPositionChanged(const QPointF &pos);
90 void newSliderPosition(const QPointF &pos);
92 private:
93 void redraw(const QSizeF &size);
94 void setXUnits();
95 void updateSliderPosition();
96 void updateSliderInfo();
97 void removeItem(QGraphicsItem *item);
98 void addItem(QGraphicsItem *item);
99 bool singleGraph() const;
100 bool gestureEvent(QGestureEvent *event);
101 void pinchGesture(QPinchGesture *gesture);
103 GraphicsScene *_scene;
105 AxisItem *_xAxis, *_yAxis;
106 AxisLabelItem *_xAxisLabel, *_yAxisLabel;
107 SliderItem *_slider;
108 SliderInfoItem *_sliderInfo;
109 InfoItem *_info;
110 GridItem *_grid;
111 QGraphicsSimpleTextItem *_message;
112 QList<GraphItem*> _graphs;
114 QRectF _bounds;
115 qreal _sliderPos;
117 qreal _xScale, _yScale;
118 qreal _yOffset;
119 QString _xUnits, _yUnits;
120 QString _xLabel, _yLabel;
121 int _precision;
122 qreal _minYRange;
124 qreal _zoom;
127 #endif // GRAPHVIEW_H