2016-02-11 20:58:52 +01:00
|
|
|
#ifndef GRAPHVIEW_H
|
|
|
|
#define GRAPHVIEW_H
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
#include <QGraphicsView>
|
2015-10-13 23:49:15 +02:00
|
|
|
#include <QGraphicsScene>
|
2015-10-05 01:43:48 +02:00
|
|
|
#include <QVector>
|
|
|
|
#include <QList>
|
|
|
|
#include <QPointF>
|
2016-02-28 09:32:54 +01:00
|
|
|
#include "palette.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;
|
|
|
|
|
2015-10-13 23:49:15 +02:00
|
|
|
class Scene : public QGraphicsScene
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
Scene(QObject *parent = 0) : QGraphicsScene(parent) {}
|
|
|
|
void mousePressEvent(QGraphicsSceneMouseEvent *e);
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void mouseClicked(const QPointF &pos);
|
|
|
|
};
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
class GraphView : public QGraphicsView
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2016-02-11 20:58:52 +01:00
|
|
|
GraphView(QWidget *parent = 0);
|
|
|
|
~GraphView();
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
void loadData(const QVector<QPointF> &data);
|
2015-10-12 01:12:12 +02:00
|
|
|
void setXLabel(const QString &label);
|
|
|
|
void setYLabel(const QString &label);
|
|
|
|
void setXUnits(const QString &units);
|
|
|
|
void setYUnits(const QString &units);
|
2015-12-19 20:23:07 +01:00
|
|
|
void setXScale(qreal scale);
|
|
|
|
void setYScale(qreal scale);
|
2016-03-17 00:50:20 +01:00
|
|
|
void setPrecision(int precision) {_precision = precision;}
|
|
|
|
void setMinRange(qreal range) {_minRange = range;}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
void plot(QPainter *painter, const QRectF &target);
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
qreal sliderPosition() const;
|
|
|
|
void setSliderPosition(qreal pos);
|
|
|
|
|
2016-03-23 09:22:26 +01:00
|
|
|
int count() const {return _graphs.count();}
|
2016-03-21 22:37:55 +01:00
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
signals:
|
|
|
|
void sliderPositionChanged(qreal);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void resizeEvent(QResizeEvent *);
|
2016-03-23 09:22:26 +01:00
|
|
|
void redraw();
|
|
|
|
void addInfo(const QString &key, const QString &value);
|
|
|
|
void clearInfo();
|
|
|
|
void skipColor() {_palette.color();}
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-12 01:12:12 +02:00
|
|
|
qreal _xScale, _yScale;
|
|
|
|
QString _xUnits, _yUnits;
|
|
|
|
QString _xLabel, _yLabel;
|
2015-10-17 01:33:02 +02:00
|
|
|
int _precision;
|
2016-03-17 00:50:20 +01:00
|
|
|
qreal _minRange;
|
2015-10-12 01:12:12 +02:00
|
|
|
|
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:
|
2015-10-12 01:12:12 +02:00
|
|
|
void createXLabel();
|
|
|
|
void createYLabel();
|
2015-10-05 01:43:48 +02:00
|
|
|
void updateBounds(const QPointF &point);
|
2016-03-23 09:22:26 +01:00
|
|
|
void redraw(const QSizeF &size);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-13 23:49:15 +02:00
|
|
|
Scene *_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;
|
|
|
|
|
2015-10-17 01:33:02 +02:00
|
|
|
QList<QGraphicsPathItem*> _graphs;
|
2015-10-12 01:12:12 +02:00
|
|
|
qreal _xMin, _xMax, _yMin, _yMax;
|
2016-03-02 09:34:39 +01:00
|
|
|
Palette _palette;
|
2015-10-05 01:43:48 +02:00
|
|
|
};
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
#endif // GRAPHVIEW_H
|