aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview/junction.cpp
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-01-08 21:43:58 +0100
committerKarel Kočí <cynerd@email.cz>2018-01-08 21:43:58 +0100
commit506174a8266eb9842ff9e50a89ddf86cb975be30 (patch)
treecd1c2905d48c172d2b83e4230b1f76dc46e8f3d3 /qtmips_gui/coreview/junction.cpp
parentbcdd7c87b1eda7dc6b294cfa0796ce7e36f12b23 (diff)
downloadqtmips-506174a8266eb9842ff9e50a89ddf86cb975be30.tar.gz
qtmips-506174a8266eb9842ff9e50a89ddf86cb975be30.tar.bz2
qtmips-506174a8266eb9842ff9e50a89ddf86cb975be30.zip
Add coreview progress
Diffstat (limited to 'qtmips_gui/coreview/junction.cpp')
-rw-r--r--qtmips_gui/coreview/junction.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/qtmips_gui/coreview/junction.cpp b/qtmips_gui/coreview/junction.cpp
new file mode 100644
index 0000000..271284c
--- /dev/null
+++ b/qtmips_gui/coreview/junction.cpp
@@ -0,0 +1,36 @@
+#include "junction.h"
+
+using namespace coreview;
+
+//////////////////////
+#define DOT_SIZE 4
+//////////////////////
+
+Junction::Junction() : QGraphicsItem(nullptr) { }
+
+Junction::~Junction() {
+ for (int i = 0; i < cons.size(); i++)
+ delete cons[i];
+}
+
+QRectF Junction::boundingRect() const {
+ return QRectF(-DOT_SIZE/2, -DOT_SIZE/2, DOT_SIZE, DOT_SIZE);
+}
+
+void Junction::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
+ painter->setBrush(QBrush(QColor(0, 0, 0)));
+ painter->drawEllipse(-DOT_SIZE/2, -DOT_SIZE/2, DOT_SIZE, DOT_SIZE);
+}
+
+void Junction::setPos(qreal x, qreal y) {
+ QGraphicsItem::setPos(x, y);
+ foreach (Connector *con, cons)
+ con->setPos(x, y);
+}
+
+Connector *Junction::new_connector(qreal angle) {
+ Connector*n = new Connector(angle);
+ cons.append(n);
+ setPos(x(), y()); // set connector's position
+ return n;
+}