Added GeoJSON and DEM files info.
[GPXSee.git] / src / GUI / graphview.h
blob83f8557d903edfe47a1f2b7aa4fc7a04c572b351
1 #ifndef GRAPHVIEW_H
2 #define GRAPHVIEW_H
4 #include <QGraphicsView>
5 #include <QList>
6 #include <QSet>
7 #include "data/graph.h"
8 #include "palette.h"
9 #include "units.h"
10 #include "infoitem.h"
13 class AxisItem;
14 class SliderItem;
15 class SliderInfoItem;
16 class GraphItem;
17 class PathItem;
18 class GridItem;
19 class QGraphicsSimpleTextItem;
21 class GraphView : public QGraphicsView
23 Q_OBJECT
25 public:
26 GraphView(QWidget *parent = 0);
27 ~GraphView();
29 bool isEmpty() const {return _graphs.isEmpty();}
30 const QList<KV> &info() const {return _info->info();}
31 void clear();
33 void plot(QPainter *painter, const QRectF &target, qreal scale);
35 void setPalette(const Palette &palette);
36 void setGraphWidth(int width);
37 void showGrid(bool show);
38 void showSliderInfo(bool show);
39 void useOpenGL(bool use);
40 void useAntiAliasing(bool use);
42 void setSliderPosition(qreal pos);
43 void setSliderColor(const QColor &color);
45 signals:
46 void sliderPositionChanged(qreal);
48 protected:
49 void addGraph(GraphItem *graph, int id = 0);
51 void showGraph(bool show, int id = 0);
52 void setGraphType(GraphType type);
53 void setUnits(Units units);
55 const QString &yLabel() const {return _yLabel;}
56 const QString &yUnits() const {return _yUnits;}
57 qreal yScale() const {return _yScale;}
58 qreal yOffset() const {return _yOffset;}
59 void setYLabel(const QString &label);
60 void setYUnits(const QString &units);
61 void setYScale(qreal scale) {_yScale = scale;}
62 void setYOffset(qreal offset) {_yOffset = offset;}
64 void setSliderPrecision(int precision) {_precision = precision;}
65 void setMinYRange(qreal range) {_minYRange = range;}
67 QRectF bounds() const;
68 void redraw();
69 void addInfo(const QString &key, const QString &value);
70 void clearInfo();
71 void skipColor() {_palette.nextColor();}
73 void changeEvent(QEvent *e);
75 QList<GraphItem*> _graphs;
76 GraphType _graphType;
78 private slots:
79 void emitSliderPositionChanged(const QPointF &pos);
80 void newSliderPosition(const QPointF &pos);
82 private:
83 void redraw(const QSizeF &size);
84 void setXUnits();
85 void createXLabel();
86 void createYLabel();
87 void updateSliderPosition();
88 void updateSliderInfo();
89 void removeItem(QGraphicsItem *item);
90 void addItem(QGraphicsItem *item);
92 void resizeEvent(QResizeEvent *e);
93 void mousePressEvent(QMouseEvent *e);
95 Units _units;
96 qreal _xScale, _yScale;
97 qreal _yOffset;
98 QString _xUnits, _yUnits;
99 QString _xLabel, _yLabel;
100 int _precision;
101 qreal _minYRange;
102 qreal _sliderPos;
104 QGraphicsScene *_scene;
106 AxisItem *_xAxis, *_yAxis;
107 SliderItem *_slider;
108 SliderInfoItem *_sliderInfo;
109 InfoItem *_info;
110 GridItem *_grid;
111 QGraphicsSimpleTextItem *_message;
113 QList<GraphItem*> _visible;
114 QSet<int> _hide;
115 QRectF _bounds;
116 Palette _palette;
117 int _width;
120 #endif // GRAPHVIEW_H