summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMateusz Piekos <mateuszpiekos@gmail.com>2012-06-24 18:37:27 (GMT)
committerMateusz Piekos <mateuszpiekos@gmail.com>2012-06-24 18:37:27 (GMT)
commit06bbc72598ece3e62b82471e474b0753d5439f00 (patch)
treeb1af2cd0717aff4e8d3427e22873b87410375cd2 /Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
parent286a3d119ec95b235b09935296450ec36e640aeb (diff)
downloadswift-contrib-06bbc72598ece3e62b82471e474b0753d5439f00.zip
swift-contrib-06bbc72598ece3e62b82471e474b0753d5439f00.tar.bz2
Added handling of rects and basic handling of polygons
Diffstat (limited to 'Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h')
-rw-r--r--Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
index 3b144cc..ebc9045 100644
--- a/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
+++ b/Swift/QtUI/Whiteboard/WhiteboardElementDrawingVisitor.h
@@ -8,6 +8,8 @@
#include <Swiften/Whiteboard/Elements/WhiteboardElementVisitor.h>
#include <Swiften/Whiteboard/Elements/WhiteboardLineElement.h>
+#include <Swiften/Whiteboard/Elements/WhiteboardPolygonElement.h>
+#include <Swiften/Whiteboard/Elements/WhiteboardTextElement.h>
#include <Swiften/Whiteboard/Elements/WhiteboardFreehandPathElement.h>
#include <Swift/QtUI/Whiteboard/GView.h>
@@ -43,6 +45,47 @@ namespace Swift {
graphicsView_->scene()->addItem(item);
}
+ void visit(WhiteboardRectElement& element) {
+ QGraphicsRectItem* item = new QGraphicsRectItem(element.getX(), element.getY(), element.getWidth(), element.getHeight());
+ QPen pen;
+ QBrush brush(Qt::SolidPattern);
+ Color penColor = element.getPenColor();
+ Color brushColor = element.getBrushColor();
+ pen.setColor(QColor(penColor.getRed(), penColor.getGreen(), penColor.getBlue(), penColor.getAlpha()));
+ pen.setWidth(element.getPenWidth());
+ brush.setColor(QColor(brushColor.getRed(), brushColor.getGreen(), brushColor.getBlue(), brushColor.getAlpha()));
+ item->setPen(pen);
+ item->setBrush(brush);
+ graphicsView_->scene()->addItem(item);
+ }
+
+ void visit(WhiteboardPolygonElement& element) {
+ QGraphicsPolygonItem* item = qgraphicsitem_cast<QGraphicsPolygonItem*>(graphicsView_->getItem(QString::fromStdString(element.getID())));
+ if (item == 0) {
+ item = new QGraphicsPolygonItem();
+ QPen pen;
+ QBrush brush(Qt::SolidPattern);
+ Color penColor = element.getPenColor();
+ Color brushColor = element.getBrushColor();
+ pen.setColor(QColor(penColor.getRed(), penColor.getGreen(), penColor.getBlue(), penColor.getAlpha()));
+ pen.setWidth(element.getPenWidth());
+ brush.setColor(QColor(brushColor.getRed(), brushColor.getGreen(), brushColor.getBlue(), brushColor.getAlpha()));
+ item->setPen(pen);
+ item->setBrush(brush);
+ graphicsView_->scene()->addItem(item);
+ }
+ QPolygonF polygon;
+ std::vector<std::pair<int, int> >::const_iterator it = element.getPoints().begin();
+ for (; it != element.getPoints().end(); ++it) {
+ polygon.append(QPointF(it->first, it->second));
+ }
+ item->setPolygon(polygon);
+ }
+
+ void visit(WhiteboardTextElement& element) {
+
+ }
+
private:
GView* graphicsView_;
};