2015-10-13 23:49:15 +02:00
|
|
|
#include <QGraphicsSceneMouseEvent>
|
2015-10-05 01:43:48 +02:00
|
|
|
#include <QEvent>
|
2016-05-22 11:54:27 +02:00
|
|
|
#include <QPaintEngine>
|
|
|
|
#include <QPaintDevice>
|
2016-02-11 20:58:52 +01:00
|
|
|
#include "config.h"
|
2016-02-12 10:09:17 +01:00
|
|
|
#include "axisitem.h"
|
2015-10-12 01:12:12 +02:00
|
|
|
#include "slideritem.h"
|
2015-10-17 01:33:02 +02:00
|
|
|
#include "sliderinfoitem.h"
|
2015-10-12 01:12:12 +02:00
|
|
|
#include "infoitem.h"
|
2016-08-16 00:27:54 +02:00
|
|
|
#include "graphitem.h"
|
2016-02-11 20:58:52 +01:00
|
|
|
#include "graphview.h"
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2015-10-17 01:33:02 +02:00
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
#define MARGIN 10.0
|
|
|
|
|
2016-08-30 08:39:14 +02:00
|
|
|
|
2015-10-13 23:49:15 +02:00
|
|
|
void Scene::mousePressEvent(QGraphicsSceneMouseEvent *e)
|
|
|
|
{
|
|
|
|
if (e->button() == Qt::LeftButton)
|
|
|
|
emit mouseClicked(e->scenePos());
|
|
|
|
|
|
|
|
QGraphicsScene::mousePressEvent(e);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
GraphView::GraphView(QWidget *parent)
|
2015-10-05 01:43:48 +02:00
|
|
|
: QGraphicsView(parent)
|
|
|
|
{
|
2015-10-13 23:49:15 +02:00
|
|
|
_scene = new Scene(this);
|
2015-10-05 01:43:48 +02:00
|
|
|
setScene(_scene);
|
|
|
|
|
2016-03-30 01:48:48 +02:00
|
|
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
_xAxis = new AxisItem(AxisItem::X);
|
2016-09-12 02:25:57 +02:00
|
|
|
_xAxis->setZValue(1.0);
|
2015-10-05 01:43:48 +02:00
|
|
|
_yAxis = new AxisItem(AxisItem::Y);
|
2016-09-12 02:25:57 +02:00
|
|
|
_yAxis->setZValue(1.0);
|
2015-10-05 01:43:48 +02:00
|
|
|
_slider = new SliderItem();
|
2015-10-12 01:12:12 +02:00
|
|
|
_slider->setZValue(2.0);
|
2016-08-16 00:27:54 +02:00
|
|
|
_sliderInfo = new SliderInfoItem(_slider);
|
|
|
|
_sliderInfo->setZValue(2.0);
|
|
|
|
_info = new InfoItem();
|
2015-10-13 23:49:15 +02:00
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
connect(_slider, SIGNAL(positionChanged(const QPointF&)), this,
|
|
|
|
SLOT(emitSliderPositionChanged(const QPointF&)));
|
2015-10-13 23:49:15 +02:00
|
|
|
connect(_scene, SIGNAL(mouseClicked(const QPointF&)), this,
|
|
|
|
SLOT(newSliderPosition(const QPointF&)));
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
_xScale = 1;
|
|
|
|
_yScale = 1;
|
2016-06-16 20:47:32 +02:00
|
|
|
_yOffset = 0;
|
2015-10-17 01:33:02 +02:00
|
|
|
|
|
|
|
_precision = 0;
|
2016-03-27 13:23:00 +02:00
|
|
|
_minYRange = 0.01;
|
2016-03-30 20:50:51 +02:00
|
|
|
|
|
|
|
_sliderPos = 0;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-08-30 21:26:28 +02:00
|
|
|
GraphView::~GraphView()
|
|
|
|
{
|
|
|
|
if (_xAxis->scene() != _scene)
|
|
|
|
delete _xAxis;
|
|
|
|
if (_yAxis->scene() != _scene)
|
|
|
|
delete _yAxis;
|
|
|
|
if (_slider->scene() != _scene)
|
|
|
|
delete _slider;
|
|
|
|
if (_info->scene() != _scene)
|
|
|
|
delete _info;
|
|
|
|
|
|
|
|
for (int i = 0; i < _graphs.count(); i++)
|
|
|
|
if (_graphs.at(i)->scene() != _scene)
|
|
|
|
delete _graphs[i];
|
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::createXLabel()
|
2015-10-12 01:12:12 +02:00
|
|
|
{
|
|
|
|
_xAxis->setLabel(QString("%1 [%2]").arg(_xLabel).arg(_xUnits));
|
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::createYLabel()
|
2015-10-12 01:12:12 +02:00
|
|
|
{
|
|
|
|
_yAxis->setLabel(QString("%1 [%2]").arg(_yLabel).arg(_yUnits));
|
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::setXLabel(const QString &label)
|
2015-10-12 01:12:12 +02:00
|
|
|
{
|
|
|
|
_xLabel = label;
|
|
|
|
createXLabel();
|
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::setYLabel(const QString &label)
|
2015-10-12 01:12:12 +02:00
|
|
|
{
|
|
|
|
_yLabel = label;
|
|
|
|
createYLabel();
|
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::setXUnits(const QString &units)
|
2015-10-12 01:12:12 +02:00
|
|
|
{
|
|
|
|
_xUnits = units;
|
|
|
|
createXLabel();
|
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::setYUnits(const QString &units)
|
2015-10-12 01:12:12 +02:00
|
|
|
{
|
|
|
|
_yUnits = units;
|
|
|
|
createYLabel();
|
|
|
|
}
|
|
|
|
|
2016-08-16 00:27:54 +02:00
|
|
|
void GraphView::loadData(const QVector<QPointF> &data, int id)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
|
|
|
QPainterPath path;
|
2016-08-16 00:27:54 +02:00
|
|
|
GraphItem *pi;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
if (data.size() < 2)
|
|
|
|
return;
|
|
|
|
|
|
|
|
path.moveTo(data.at(0).x(), -data.at(0).y());
|
|
|
|
for (int i = 1; i < data.size(); i++) {
|
2016-03-19 09:06:43 +01:00
|
|
|
const QPointF &p = data.at(i);
|
|
|
|
path.lineTo(p.x(), -p.y());
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-08-16 00:27:54 +02:00
|
|
|
pi = new GraphItem(path);
|
|
|
|
pi->setId(id);
|
2016-08-19 19:48:44 +02:00
|
|
|
pi->setColor(_palette.color());
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
_graphs.append(pi);
|
2016-08-19 19:48:44 +02:00
|
|
|
|
|
|
|
if (!_hide.contains(id)) {
|
|
|
|
_visible.append(pi);
|
|
|
|
_scene->addItem(pi);
|
|
|
|
updateBounds(path);
|
|
|
|
}
|
2015-12-19 20:23:07 +01:00
|
|
|
}
|
|
|
|
|
2016-08-30 08:39:14 +02:00
|
|
|
void GraphView::removeItem(QGraphicsItem *item)
|
|
|
|
{
|
|
|
|
if (item->scene() == _scene)
|
|
|
|
_scene->removeItem(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphView::addItem(QGraphicsItem *item)
|
|
|
|
{
|
|
|
|
if (item->scene() != _scene)
|
|
|
|
_scene->addItem(item);
|
|
|
|
}
|
|
|
|
|
2016-08-16 00:27:54 +02:00
|
|
|
void GraphView::showGraph(bool show, int id)
|
|
|
|
{
|
|
|
|
if (show)
|
|
|
|
_hide.remove(id);
|
|
|
|
else
|
|
|
|
_hide.insert(id);
|
2016-08-19 19:48:44 +02:00
|
|
|
|
|
|
|
_visible.clear();
|
|
|
|
_bounds = QRectF();
|
|
|
|
for (int i = 0; i < _graphs.count(); i++) {
|
|
|
|
GraphItem* gi = _graphs.at(i);
|
2016-08-30 08:39:14 +02:00
|
|
|
if (_hide.contains(gi->id()))
|
|
|
|
removeItem(gi);
|
|
|
|
else {
|
|
|
|
addItem(gi);
|
2016-08-19 19:48:44 +02:00
|
|
|
_visible.append(gi);
|
|
|
|
updateBounds(gi->path());
|
|
|
|
}
|
|
|
|
}
|
2016-08-16 00:27:54 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::redraw()
|
2015-12-19 20:23:07 +01:00
|
|
|
{
|
2016-08-19 19:48:44 +02:00
|
|
|
redraw(viewport()->size() - QSizeF(MARGIN, MARGIN));
|
|
|
|
}
|
|
|
|
|
|
|
|
void GraphView::updateBounds(const QPainterPath &path)
|
|
|
|
{
|
|
|
|
QRectF br = path.boundingRect();
|
|
|
|
br.moveTopLeft(QPointF(br.left(), -br.top() - br.height()));
|
|
|
|
_bounds |= br;
|
|
|
|
}
|
|
|
|
|
|
|
|
QRectF GraphView::graphsBoundingRect() const
|
|
|
|
{
|
|
|
|
QRectF rect;
|
|
|
|
|
|
|
|
for (int i = 0; i < _visible.count(); i++)
|
|
|
|
rect |= _visible.at(i)->boundingRect();
|
|
|
|
|
|
|
|
return rect;
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-03-23 09:22:26 +01:00
|
|
|
void GraphView::redraw(const QSizeF &size)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
|
|
|
QRectF r;
|
|
|
|
QSizeF mx, my;
|
2016-03-27 13:23:00 +02:00
|
|
|
RangeF rx, ry;
|
2015-10-05 01:43:48 +02:00
|
|
|
QTransform transform;
|
2016-03-27 13:23:00 +02:00
|
|
|
qreal xs, ys;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
|
2016-08-30 08:39:14 +02:00
|
|
|
if (_visible.isEmpty()) {
|
|
|
|
removeItem(_xAxis);
|
|
|
|
removeItem(_yAxis);
|
|
|
|
removeItem(_slider);
|
|
|
|
removeItem(_info);
|
|
|
|
_scene->setSceneRect(QRectF());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
addItem(_xAxis);
|
|
|
|
addItem(_yAxis);
|
|
|
|
addItem(_slider);
|
|
|
|
addItem(_info);
|
|
|
|
|
2016-03-27 13:23:00 +02:00
|
|
|
rx = RangeF(_bounds.left() * _xScale, _bounds.right() * _xScale);
|
2016-06-16 20:47:32 +02:00
|
|
|
ry = RangeF(_bounds.top() * _yScale + _yOffset, _bounds.bottom() * _yScale
|
|
|
|
+ _yOffset);
|
2016-03-27 13:23:00 +02:00
|
|
|
if (ry.size() < _minYRange)
|
|
|
|
ry.resize(_minYRange);
|
|
|
|
|
2016-03-17 00:50:20 +01:00
|
|
|
_xAxis->setRange(rx);
|
|
|
|
_yAxis->setRange(ry);
|
2015-10-05 01:43:48 +02:00
|
|
|
mx = _xAxis->margin();
|
|
|
|
my = _yAxis->margin();
|
2016-03-17 00:50:20 +01:00
|
|
|
|
2016-08-19 19:48:44 +02:00
|
|
|
r = graphsBoundingRect();
|
2016-03-27 13:23:00 +02:00
|
|
|
if (r.height() < _minYRange)
|
|
|
|
r.adjust(0, -(_minYRange/2 - r.height()/2), 0,
|
|
|
|
_minYRange/2 - r.height()/2);
|
2016-03-17 00:50:20 +01:00
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
xs = (size.width() - (my.width() + mx.width())) / r.width();
|
2015-10-12 01:12:12 +02:00
|
|
|
ys = (size.height() - (mx.height() + my.height())
|
|
|
|
- _info->boundingRect().height()) / r.height();
|
2015-10-05 01:43:48 +02:00
|
|
|
transform.scale(xs, ys);
|
|
|
|
|
2016-08-19 19:48:44 +02:00
|
|
|
for (int i = 0; i < _visible.size(); i++)
|
|
|
|
_visible.at(i)->setTransform(transform);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-08-19 19:48:44 +02:00
|
|
|
QPointF p(r.left() * xs, r.top() * ys);
|
|
|
|
QSizeF s(r.width() * xs, r.height() * ys);
|
|
|
|
r = QRectF(p, s);
|
2016-03-27 13:23:00 +02:00
|
|
|
if (r.height() < _minYRange * ys)
|
|
|
|
r.adjust(0, -(_minYRange/2 * ys - r.height()/2), 0,
|
|
|
|
(_minYRange/2) * ys - r.height()/2);
|
2016-03-17 00:50:20 +01:00
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
_xAxis->setSize(r.width());
|
|
|
|
_yAxis->setSize(r.height());
|
|
|
|
_xAxis->setPos(r.bottomLeft());
|
|
|
|
_yAxis->setPos(r.bottomLeft());
|
|
|
|
|
|
|
|
_slider->setArea(r);
|
2016-08-16 00:27:54 +02:00
|
|
|
updateSliderPosition();
|
2015-12-19 20:49:22 +01:00
|
|
|
|
2016-08-19 19:48:44 +02:00
|
|
|
r |= _xAxis->sceneBoundingRect();
|
|
|
|
r |= _yAxis->sceneBoundingRect();
|
2015-10-12 01:12:12 +02:00
|
|
|
_info->setPos(r.topLeft() + QPointF(r.width()/2
|
|
|
|
- _info->boundingRect().width()/2, -_info->boundingRect().height()));
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
_scene->setSceneRect(_scene->itemsBoundingRect());
|
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::resizeEvent(QResizeEvent *)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2016-08-19 19:48:44 +02:00
|
|
|
redraw();
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::plot(QPainter *painter, const QRectF &target)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2016-05-22 11:54:27 +02:00
|
|
|
qreal ratio = painter->paintEngine()->paintDevice()->logicalDpiX()
|
|
|
|
/ SCREEN_DPI;
|
|
|
|
QSizeF canvas = QSizeF(target.width() / ratio, target.height() / ratio);
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-05-20 22:44:03 +02:00
|
|
|
setUpdatesEnabled(false);
|
2016-03-23 09:22:26 +01:00
|
|
|
redraw(canvas);
|
2016-05-21 16:10:24 +02:00
|
|
|
if (_slider->pos().x() == _slider->area().left())
|
|
|
|
_slider->hide();
|
2016-05-22 11:54:27 +02:00
|
|
|
_scene->render(painter, target);
|
2015-10-19 00:35:08 +02:00
|
|
|
_slider->show();
|
2016-05-20 23:47:37 +02:00
|
|
|
redraw();
|
2016-05-20 22:44:03 +02:00
|
|
|
setUpdatesEnabled(true);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::clear()
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2015-12-19 20:23:07 +01:00
|
|
|
_slider->clear();
|
2015-10-13 00:27:49 +02:00
|
|
|
_info->clear();
|
2016-08-19 19:48:44 +02:00
|
|
|
|
|
|
|
for (int i = 0; i < _graphs.count(); i++)
|
|
|
|
delete _graphs[i];
|
|
|
|
|
2015-10-05 01:43:48 +02:00
|
|
|
_graphs.clear();
|
2016-08-19 19:48:44 +02:00
|
|
|
_visible.clear();
|
2016-03-02 09:34:39 +01:00
|
|
|
_palette.reset();
|
2015-10-05 01:43:48 +02:00
|
|
|
|
2016-03-27 13:23:00 +02:00
|
|
|
_bounds = QRectF();
|
2016-03-30 20:50:51 +02:00
|
|
|
_sliderPos = 0;
|
2015-10-05 01:43:48 +02:00
|
|
|
|
|
|
|
_scene->setSceneRect(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
2016-03-22 19:19:59 +01:00
|
|
|
static qreal yAtX(const QPainterPath &path, qreal x)
|
|
|
|
{
|
|
|
|
int low = 0;
|
|
|
|
int high = path.elementCount() - 1;
|
|
|
|
int mid = 0;
|
|
|
|
|
2016-04-01 19:20:55 +02:00
|
|
|
Q_ASSERT(high > low);
|
|
|
|
Q_ASSERT(x >= path.elementAt(low).x && x <= path.elementAt(high).x);
|
|
|
|
|
2016-03-22 19:19:59 +01:00
|
|
|
while (low <= high) {
|
|
|
|
mid = low + ((high - low) / 2);
|
|
|
|
const QPainterPath::Element &e = path.elementAt(mid);
|
|
|
|
if (e.x > x)
|
|
|
|
high = mid - 1;
|
|
|
|
else if (e.x < x)
|
|
|
|
low = mid + 1;
|
|
|
|
else
|
|
|
|
return e.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
QLineF l;
|
2016-04-01 19:20:55 +02:00
|
|
|
if (path.elementAt(mid).x < x)
|
2016-03-22 19:19:59 +01:00
|
|
|
l = QLineF(path.elementAt(mid).x, path.elementAt(mid).y,
|
|
|
|
path.elementAt(mid+1).x, path.elementAt(mid+1).y);
|
2016-04-01 19:20:55 +02:00
|
|
|
else
|
2016-03-22 19:19:59 +01:00
|
|
|
l = QLineF(path.elementAt(mid-1).x, path.elementAt(mid-1).y,
|
|
|
|
path.elementAt(mid).x, path.elementAt(mid).y);
|
|
|
|
|
|
|
|
return l.pointAt((x - l.p1().x()) / (l.p2().x() - l.p1().x())).y();
|
|
|
|
}
|
|
|
|
|
2016-08-16 00:27:54 +02:00
|
|
|
void GraphView::updateSliderPosition()
|
|
|
|
{
|
2016-08-19 19:48:44 +02:00
|
|
|
if (_bounds.width() <= 0)
|
|
|
|
return;
|
2016-08-16 00:27:54 +02:00
|
|
|
|
2016-08-16 10:25:08 +02:00
|
|
|
if (_sliderPos <= _bounds.right() && _sliderPos >= _bounds.left()) {
|
|
|
|
_slider->setPos((_sliderPos / _bounds.width()) * _slider->area().width(),
|
|
|
|
_slider->area().bottom());
|
2016-08-19 19:48:44 +02:00
|
|
|
_slider->setVisible(!_visible.isEmpty());
|
|
|
|
} else {
|
|
|
|
_slider->setPos(_slider->area().left(), _slider->area().bottom());
|
2016-08-16 10:25:08 +02:00
|
|
|
_slider->setVisible(false);
|
2016-08-19 19:48:44 +02:00
|
|
|
}
|
2016-08-16 00:27:54 +02:00
|
|
|
|
|
|
|
updateSliderInfo();
|
|
|
|
}
|
|
|
|
|
2016-03-30 20:50:51 +02:00
|
|
|
void GraphView::updateSliderInfo()
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2016-08-19 19:48:44 +02:00
|
|
|
_sliderInfo->setVisible(_visible.count() == 1);
|
2016-06-27 20:29:59 +02:00
|
|
|
if (!_sliderInfo->isVisible())
|
2016-03-22 19:19:59 +01:00
|
|
|
return;
|
|
|
|
|
2016-08-19 19:48:44 +02:00
|
|
|
const QPainterPath &path = _visible.first()->path();
|
2016-03-17 00:50:20 +01:00
|
|
|
QRectF br = path.boundingRect();
|
2016-03-27 13:23:00 +02:00
|
|
|
if (br.height() < _minYRange)
|
|
|
|
br.adjust(0, -(_minYRange/2 - br.height()/2), 0,
|
|
|
|
_minYRange/2 - br.height()/2);
|
2016-03-22 19:19:59 +01:00
|
|
|
|
2016-03-30 20:50:51 +02:00
|
|
|
qreal y = yAtX(path, _sliderPos);
|
2016-03-22 19:19:59 +01:00
|
|
|
qreal r = (y - br.bottom()) / br.height();
|
2016-03-30 01:48:48 +02:00
|
|
|
|
2016-03-30 20:50:51 +02:00
|
|
|
qreal pos = (_sliderPos / _bounds.width()) * _slider->area().width();
|
|
|
|
SliderInfoItem::Side s = (pos + _sliderInfo->boundingRect().width()
|
2016-03-30 01:48:48 +02:00
|
|
|
> _slider->area().right()) ? SliderInfoItem::Left : SliderInfoItem::Right;
|
|
|
|
|
|
|
|
_sliderInfo->setSide(s);
|
2015-10-17 01:33:02 +02:00
|
|
|
_sliderInfo->setPos(QPointF(0, _slider->boundingRect().height() * r));
|
2016-06-16 20:47:32 +02:00
|
|
|
_sliderInfo->setText(QString::number(-y * _yScale + _yOffset, 'f',
|
|
|
|
_precision));
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-03-30 20:50:51 +02:00
|
|
|
void GraphView::emitSliderPositionChanged(const QPointF &pos)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2016-08-19 19:48:44 +02:00
|
|
|
if (_slider->area().width() <= 0)
|
|
|
|
return;
|
2016-03-30 20:50:51 +02:00
|
|
|
|
|
|
|
_sliderPos = (pos.x() / _slider->area().width()) * _bounds.width();
|
2016-08-16 00:27:54 +02:00
|
|
|
updateSliderPosition();
|
2016-08-19 19:48:44 +02:00
|
|
|
|
2016-08-16 00:27:54 +02:00
|
|
|
emit sliderPositionChanged(_sliderPos);
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::setSliderPosition(qreal pos)
|
2015-10-05 01:43:48 +02:00
|
|
|
{
|
2016-08-19 19:48:44 +02:00
|
|
|
if (_visible.isEmpty())
|
2016-03-23 09:22:26 +01:00
|
|
|
return;
|
|
|
|
|
2016-08-16 00:27:54 +02:00
|
|
|
_sliderPos = pos;
|
|
|
|
updateSliderPosition();
|
2015-10-05 01:43:48 +02:00
|
|
|
}
|
2015-10-12 01:12:12 +02:00
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::newSliderPosition(const QPointF &pos)
|
2015-10-13 23:49:15 +02:00
|
|
|
{
|
2016-08-16 00:27:54 +02:00
|
|
|
if (_slider->area().contains(pos))
|
2016-08-19 19:48:44 +02:00
|
|
|
_slider->setPos(pos);
|
2015-10-13 23:49:15 +02:00
|
|
|
}
|
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::addInfo(const QString &key, const QString &value)
|
2015-10-12 01:12:12 +02:00
|
|
|
{
|
|
|
|
_info->insert(key, value);
|
|
|
|
}
|
2015-12-19 20:23:07 +01:00
|
|
|
|
2016-02-11 20:58:52 +01:00
|
|
|
void GraphView::clearInfo()
|
2015-12-19 20:23:07 +01:00
|
|
|
{
|
|
|
|
_info->clear();
|
|
|
|
}
|