aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview/junction.cpp
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2018-01-21 11:36:34 +0100
committerKarel Kočí <cynerd@email.cz>2018-01-21 11:36:34 +0100
commit16b1544fff7e9ca11deb3ae1b891c79eac7ec50e (patch)
treee9f04ca11d330e1e47469bb7471d6abcb25c8d49 /qtmips_gui/coreview/junction.cpp
parent507e81b60af88721780a1eb5591d884d1667c4b4 (diff)
downloadqtmips-16b1544fff7e9ca11deb3ae1b891c79eac7ec50e.tar.gz
qtmips-16b1544fff7e9ca11deb3ae1b891c79eac7ec50e.tar.bz2
qtmips-16b1544fff7e9ca11deb3ae1b891c79eac7ec50e.zip
Implement little bit more of scheme and fix connection angle
This commit adds few more bits to scheme but mainly it chnages how connectors specify angles. Originally it was in radians but we was mapping that trough mathematical operations directly to sizes. But that was problematic because of floating point inacuracy and we sometimes founded intersection where there should be one. So this commit gets rid of this at all and instead allows just some fixes axes to be used instead of arbitrary angles.
Diffstat (limited to 'qtmips_gui/coreview/junction.cpp')
-rw-r--r--qtmips_gui/coreview/junction.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/qtmips_gui/coreview/junction.cpp b/qtmips_gui/coreview/junction.cpp
index 271284c..494aca6 100644
--- a/qtmips_gui/coreview/junction.cpp
+++ b/qtmips_gui/coreview/junction.cpp
@@ -6,7 +6,9 @@ using namespace coreview;
#define DOT_SIZE 4
//////////////////////
-Junction::Junction() : QGraphicsItem(nullptr) { }
+Junction::Junction(bool point) : QGraphicsItem(nullptr) {
+ this->point = point;
+}
Junction::~Junction() {
for (int i = 0; i < cons.size(); i++)
@@ -14,11 +16,17 @@ Junction::~Junction() {
}
QRectF Junction::boundingRect() const {
- return QRectF(-DOT_SIZE/2, -DOT_SIZE/2, DOT_SIZE, DOT_SIZE);
+ if (point)
+ return QRectF(-DOT_SIZE/2, -DOT_SIZE/2, DOT_SIZE, DOT_SIZE);
+ else
+ return QRectF();
}
void Junction::paint(QPainter *painter, const QStyleOptionGraphicsItem *option __attribute__((unused)), QWidget *widget __attribute__((unused))) {
+ if (!point)
+ return;
painter->setBrush(QBrush(QColor(0, 0, 0)));
+ painter->setPen(QPen(Qt::NoPen)); // Disable pen (render only brush)
painter->drawEllipse(-DOT_SIZE/2, -DOT_SIZE/2, DOT_SIZE, DOT_SIZE);
}
@@ -28,8 +36,8 @@ void Junction::setPos(qreal x, qreal y) {
con->setPos(x, y);
}
-Connector *Junction::new_connector(qreal angle) {
- Connector*n = new Connector(angle);
+Connector *Junction::new_connector(enum Connector::Axis axis) {
+ Connector*n = new Connector(axis);
cons.append(n);
setPos(x(), y()); // set connector's position
return n;