aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview/multiplexer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'qtmips_gui/coreview/multiplexer.cpp')
-rw-r--r--qtmips_gui/coreview/multiplexer.cpp18
1 files changed, 10 insertions, 8 deletions
diff --git a/qtmips_gui/coreview/multiplexer.cpp b/qtmips_gui/coreview/multiplexer.cpp
index f0eebef..bd2fbd9 100644
--- a/qtmips_gui/coreview/multiplexer.cpp
+++ b/qtmips_gui/coreview/multiplexer.cpp
@@ -45,9 +45,9 @@ using namespace coreview;
#define PENW 1
//////////////////////
-Multiplexer::Multiplexer(unsigned size, bool ctl_up) {
+Multiplexer::Multiplexer(unsigned size, bool ctl_up): QGraphicsObject(nullptr) {
this->size = size;
- seton = 0;
+ seton = -1;
ctlfrom = ctl_up;
con_ctl = new Connector(Connector::AX_Y);
con_out = new Connector(Connector::AX_X);
@@ -72,9 +72,9 @@ QRectF Multiplexer::boundingRect() const {
}
void Multiplexer::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
- painter->setPen(QColor(200, 200, 200));
- if (seton > 0 && seton <= size)
- painter->drawLine(0, (HEIGHT / 2) + ((seton - 1) * GAP), WIDTH, C_HEIGHT / 2);
+ painter->setPen(QPen(QColor(200, 200, 200), 2));
+ if (seton >= 0 && seton < (int)size)
+ painter->drawLine(0, (HEIGHT / 2) + (seton * GAP), WIDTH, C_HEIGHT / 2);
painter->setPen(QColor(0, 0, 0));
const QPointF poly[] = {
@@ -110,8 +110,10 @@ const Connector *Multiplexer::connector_in(unsigned i) const {
return con_in[i];
}
-void Multiplexer::set(unsigned i) {
- seton = i;
- update();
+void Multiplexer::set(std::uint32_t i) {
+ if (seton != (int)i) {
+ seton = (int)i;
+ update();
+ }
}