From 59feffc5a253fec33b310f7a0105c8ef42b9019b Mon Sep 17 00:00:00 2001 From: Javier Date: Sun, 14 Jun 2015 01:35:25 +0200 Subject: paperreplay working --- stfgraphicsitem.cc | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'stfgraphicsitem.cc') diff --git a/stfgraphicsitem.cc b/stfgraphicsitem.cc index 414cf6c..3c3a48b 100644 --- a/stfgraphicsitem.cc +++ b/stfgraphicsitem.cc @@ -2,38 +2,51 @@ #include #include "stfreader.h" +#include "smartpen.h" +#include "stfstrokeitem.h" #include "stfgraphicsitem.h" class StfToGraphicsPathItems : public StfReader::StrokeHandler { QGraphicsItem *parent; + PaperReplay::SessionList replays; + PaperReplay::Session replay; + qint64 startTime, lastTime; QPainterPath path; QRectF bound; public: - StfToGraphicsPathItems(QGraphicsItem* parent) - : parent(parent), path(), bound(0.0, 0.0, 1.0, 1.0) { + StfToGraphicsPathItems(const PaperReplay::SessionList &replays, QGraphicsItem* parent) + : parent(parent), replays(replays), path(), bound(0.0, 0.0, 1.0, 1.0) { } ~StfToGraphicsPathItems() { } - bool startStroke(const QPoint& p, int force, quint64 time) { + bool startStroke(const QPoint& p, int force, qint64 time) { Q_UNUSED(force); - Q_UNUSED(time); + QList sessions = replays.sessionsDuringTime(time); + if (!sessions.isEmpty()) { + replay = sessions.first(); + } else { + replay = PaperReplay::Session(); + } + startTime = time; + lastTime = time; path = QPainterPath(QPointF(p)); return true; } - bool strokePoint(const QPoint& p, int force, quint64 time) { + bool strokePoint(const QPoint& p, int force, qint64 time) { Q_UNUSED(force); Q_UNUSED(time); + lastTime = time; path.lineTo(QPointF(p)); return true; } bool endStroke() { bound |= path.boundingRect(); - new QGraphicsPathItem(path, parent); + new StfStrokeItem(path, replay, startTime, lastTime, parent); /* Parent will take the child down with him when deleted. */ return true; } @@ -43,12 +56,12 @@ public: } }; -StfGraphicsItem::StfGraphicsItem(QIODevice *dev, QGraphicsItem *parent) : +StfGraphicsItem::StfGraphicsItem(QIODevice *dev, const PaperReplay::SessionList &replays, QGraphicsItem *parent) : QGraphicsItem(parent) { setFlags(ItemHasNoContents); - StfToGraphicsPathItems h(this); + StfToGraphicsPathItems h(replays, this); StfReader r; r.setStrokeHandler(&h); if (r.parse(dev)) { -- cgit v1.2.3