summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-21 18:05:56 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-21 18:05:56 (GMT)
commit286a3d119ec95b235b09935296450ec36e640aeb (patch)
tree9146c0ebb21745bb985d24378829929ce92529e2 /Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
parente0c79b3b885f126a2a2a34cb0d5df90796821130 (diff)
downloadswift-contrib-286a3d119ec95b235b09935296450ec36e640aeb.zip
swift-contrib-286a3d119ec95b235b09935296450ec36e640aeb.tar.bz2
Added parsing and serialization of freehand path element
Diffstat (limited to 'Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h')
-rw-r--r--Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
index a1715bc..3b144cc 100644
--- a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
+++ b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
@@ -8,6 +8,7 @@
#include <Swiften/Whiteboard/Elements/WhiteboardElementVisitor.h>
#include <Swiften/Whiteboard/Elements/WhiteboardLineElement.h>
+#include <Swiften/Whiteboard/Elements/WhiteboardFreehandPathElement.h>
#include <Swift/QtUI/Whiteboard/GView.h>
namespace Swift {
@@ -15,16 +16,33 @@ namespace Swift {
public:
WhiteboardElementDrawingVisitor(GView* graphicsView) : graphicsView_(graphicsView) {}
- void visit(const WhiteboardLineElement* element) {
- QGraphicsLineItem *item = new QGraphicsLineItem(element->x1(), element->y1(), element->x2(), element->y2());
+ void visit(WhiteboardLineElement& element) {
+ QGraphicsLineItem *item = new QGraphicsLineItem(element.x1(), element.y1(), element.x2(), element.y2());
QPen pen;
- Color color = element->getColor();
+ Color color = element.getColor();
pen.setColor(QColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()));
- pen.setWidth(element->getPenWidth());
+ pen.setWidth(element.getPenWidth());
item->setPen(pen);
graphicsView_->scene()->addItem(item);
}
+ void visit(WhiteboardFreehandPathElement& element) {
+ FreehandLineItem *item = new FreehandLineItem;
+ QPen pen;
+ Color color = element.getColor();
+ pen.setColor(QColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()));
+ pen.setWidth(element.getPenWidth());
+ item->setPen(pen);
+
+ std::vector<std::pair<int, int> >::const_iterator it = element.getPoints().begin();
+ item->setStartPoint(QPointF(it->first, it->second));
+ for (++it; it != element.getPoints().end(); ++it) {
+ item->lineTo(QPointF(it->first, it->second));
+ }
+
+ graphicsView_->scene()->addItem(item);
+ }
+
private:
GView* graphicsView_;
};