aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2017-12-17 13:32:42 +0100
committerKarel Kočí <cynerd@email.cz>2017-12-17 13:32:42 +0100
commitc11d282cdc2fdf4668d4dc2710968daa17a0ffc6 (patch)
tree04f36950e57cf8850445e5dcb7ab6bdd4434eaf5 /qtmips_gui/coreview
parentd16d824c0649c03cf79c5820660318396e3b96ab (diff)
downloadqtmips-c11d282cdc2fdf4668d4dc2710968daa17a0ffc6.tar.gz
qtmips-c11d282cdc2fdf4668d4dc2710968daa17a0ffc6.tar.bz2
qtmips-c11d282cdc2fdf4668d4dc2710968daa17a0ffc6.zip
Use drawPolygon more and better way
Diffstat (limited to 'qtmips_gui/coreview')
-rw-r--r--qtmips_gui/coreview/latch.cpp2
-rw-r--r--qtmips_gui/coreview/multiplexer.cpp15
2 files changed, 9 insertions, 8 deletions
diff --git a/qtmips_gui/coreview/latch.cpp b/qtmips_gui/coreview/latch.cpp
index 52f6eb3..0ad827a 100644
--- a/qtmips_gui/coreview/latch.cpp
+++ b/qtmips_gui/coreview/latch.cpp
@@ -24,7 +24,7 @@ void Latch::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWi
QPointF(WIDTH/2, WIDTH/2),
QPointF(WIDTH, 0)
};
- painter->drawPolygon(tickPolygon, 3);
+ painter->drawPolygon(tickPolygon, sizeof(tickPolygon) / sizeof(QPointF));
}
void Latch::setPos(qreal x, qreal y) {
diff --git a/qtmips_gui/coreview/multiplexer.cpp b/qtmips_gui/coreview/multiplexer.cpp
index 57fa443..148c58d 100644
--- a/qtmips_gui/coreview/multiplexer.cpp
+++ b/qtmips_gui/coreview/multiplexer.cpp
@@ -33,15 +33,16 @@ QRectF Multiplexer::boundingRect() const {
}
void Multiplexer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) {
- // Draw pointing line first so it isn't over the border lines
+ const QPointF poly[] = {
+ QPointF(0, 0),
+ QPointF(WIDTH, WIDTH),
+ QPointF(WIDTH, (HEIGHT * size) - WIDTH),
+ QPointF(0, HEIGHT * size)
+ };
+ painter->drawPolygon(poly, sizeof(poly) / sizeof(QPointF));
+
painter->setPen(QColor(200, 200, 200));
painter->drawLine(0, (HEIGHT / 2) + (seton * HEIGHT), WIDTH, (HEIGHT * size) / 2);
-
- painter->setPen(QColor());
- painter->drawLine(0, 0, 0, (HEIGHT * size)); // (|)
- painter->drawLine(0, 0, WIDTH, WIDTH); // (\)
- painter->drawLine(0, (HEIGHT * size), WIDTH, (HEIGHT * size) - WIDTH); // (/)
- painter->drawLine(WIDTH, WIDTH, WIDTH, (HEIGHT * size) - WIDTH); // (|)
}
void Multiplexer::setPos(qreal x, qreal y) {