1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-07 07:13:21 +02:00
GPXSee/src/GUI/graphview.h

115 lines
2.5 KiB
C
Raw Normal View History

#ifndef GRAPHVIEW_H
#define GRAPHVIEW_H
2015-10-05 01:43:48 +02:00
#include <QGraphicsView>
#include <QList>
#include <QSet>
2017-11-26 18:54:03 +01:00
#include "data/graph.h"
2016-02-28 09:32:54 +01:00
#include "palette.h"
2016-09-19 00:56:10 +02:00
#include "units.h"
2015-10-05 01:43:48 +02:00
2016-02-12 10:09:17 +01:00
class AxisItem;
2015-10-12 01:12:12 +02:00
class SliderItem;
2015-10-17 01:33:02 +02:00
class SliderInfoItem;
2015-10-12 01:12:12 +02:00
class InfoItem;
class GraphItem;
2016-09-19 00:56:10 +02:00
class PathItem;
2016-10-17 23:14:07 +02:00
class GridItem;
2015-10-12 01:12:12 +02:00
class GraphView : public QGraphicsView
2015-10-05 01:43:48 +02:00
{
Q_OBJECT
public:
GraphView(QWidget *parent = 0);
~GraphView();
2015-10-05 01:43:48 +02:00
2017-10-04 23:15:39 +02:00
bool isEmpty() const {return _graphs.isEmpty();}
2016-03-27 13:23:00 +02:00
void clear();
2017-10-04 23:15:39 +02:00
void plot(QPainter *painter, const QRectF &target, qreal scale);
2016-03-27 13:23:00 +02:00
2016-12-06 01:48:26 +01:00
void setPalette(const Palette &palette);
void setGraphWidth(int width);
2017-10-04 23:15:39 +02:00
void showGrid(bool show);
void showSliderInfo(bool show);
void useOpenGL(bool use);
void useAntiAliasing(bool use);
void setSliderPosition(qreal pos);
signals:
void sliderPositionChanged(qreal);
protected:
void addGraph(GraphItem *graph, PathItem *path, int id = 0);
void showGraph(bool show, int id = 0);
void setGraphType(GraphType type);
void setUnits(Units units);
2016-12-06 01:48:26 +01:00
2016-03-27 13:23:00 +02:00
const QString &yLabel() const {return _yLabel;}
const QString &yUnits() const {return _yUnits;}
qreal yScale() const {return _yScale;}
2016-06-16 20:47:32 +02:00
qreal yOffset() const {return _yOffset;}
2015-10-12 01:12:12 +02:00
void setYLabel(const QString &label);
void setYUnits(const QString &units);
2016-06-16 20:47:32 +02:00
void setYScale(qreal scale) {_yScale = scale;}
void setYOffset(qreal offset) {_yOffset = offset;}
2015-10-05 01:43:48 +02:00
2016-03-27 13:23:00 +02:00
void setSliderPrecision(int precision) {_precision = precision;}
void setMinYRange(qreal range) {_minYRange = range;}
2015-10-05 01:43:48 +02:00
2016-09-26 10:09:56 +02:00
QRectF bounds() const;
2017-10-04 23:15:39 +02:00
void redraw();
2016-03-27 13:23:00 +02:00
void redraw(const QSizeF &size);
void addInfo(const QString &key, const QString &value);
void clearInfo();
2016-12-06 01:48:26 +01:00
void skipColor() {_palette.nextColor();}
2015-10-05 01:43:48 +02:00
2017-09-25 19:56:04 +02:00
QList<GraphItem*> _graphs;
GraphType _graphType;
2015-10-05 01:43:48 +02:00
private slots:
void emitSliderPositionChanged(const QPointF &pos);
2015-10-13 23:49:15 +02:00
void newSliderPosition(const QPointF &pos);
2015-10-05 01:43:48 +02:00
private:
2016-09-19 00:56:10 +02:00
void setXUnits();
2015-10-12 01:12:12 +02:00
void createXLabel();
void createYLabel();
void updateSliderPosition();
2016-03-30 20:50:51 +02:00
void updateSliderInfo();
2016-08-30 08:39:14 +02:00
void removeItem(QGraphicsItem *item);
void addItem(QGraphicsItem *item);
2016-03-27 13:23:00 +02:00
2016-10-29 18:01:25 +02:00
void resizeEvent(QResizeEvent *);
void mousePressEvent(QMouseEvent *);
2017-10-04 23:15:39 +02:00
Units _units;
2016-03-27 13:23:00 +02:00
qreal _xScale, _yScale;
2016-06-16 20:47:32 +02:00
qreal _yOffset;
2016-03-27 13:23:00 +02:00
QString _xUnits, _yUnits;
QString _xLabel, _yLabel;
int _precision;
qreal _minYRange;
2016-03-30 20:50:51 +02:00
qreal _sliderPos;
2015-10-05 01:43:48 +02:00
2016-10-29 18:01:25 +02:00
QGraphicsScene *_scene;
2015-10-17 01:33:02 +02:00
2015-10-05 01:43:48 +02:00
AxisItem *_xAxis, *_yAxis;
SliderItem *_slider;
2015-10-17 01:33:02 +02:00
SliderInfoItem *_sliderInfo;
2015-10-12 01:12:12 +02:00
InfoItem *_info;
2016-10-17 23:14:07 +02:00
GridItem *_grid;
2015-10-12 01:12:12 +02:00
2016-08-19 19:48:44 +02:00
QList<GraphItem*> _visible;
QSet<int> _hide;
2016-03-27 13:23:00 +02:00
QRectF _bounds;
2016-03-02 09:34:39 +01:00
Palette _palette;
2016-12-06 01:48:26 +01:00
int _width;
2015-10-05 01:43:48 +02:00
};
#endif // GRAPHVIEW_H