aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview/connection.h
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/connection.h
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/connection.h')
-rw-r--r--qtmips_gui/coreview/connection.h54
1 files changed, 42 insertions, 12 deletions
diff --git a/qtmips_gui/coreview/connection.h b/qtmips_gui/coreview/connection.h
index 0ee981e..88ad1da 100644
--- a/qtmips_gui/coreview/connection.h
+++ b/qtmips_gui/coreview/connection.h
@@ -10,21 +10,30 @@ namespace coreview {
class Connector : public QObject {
Q_OBJECT
public:
- Connector(qreal angle);
+ enum Axis {
+ AX_X, // X axis
+ AX_Y, // Y axis
+ AX_XY, // X=Y axis (45°)
+ AX_MXY // X=-Y axis (-45°)
+ };
+
+ Connector(enum Axis axis = AX_X);
void setPos(qreal x, qreal y);
+
+ enum Axis axis() const;
qreal x() const;
qreal y() const;
+
QPointF point() const;
QLineF vector() const;
- qreal angle() const;
-
signals:
- void updated(QPointF);
+ void updated(QPointF point);
+ void updated(QLineF vector);
private:
- qreal ang;
+ enum Axis ax;
qreal qx, qy;
};
@@ -42,22 +51,43 @@ public:
void setAxes(QVector<QLineF>);
private slots:
- void moved_start(QPointF);
- void moved_end(QPointF);
+ void moved_start(QLineF);
+ void moved_end(QLineF);
-private:
+protected:
QGraphicsSimpleTextItem *value;
QVector<QPointF> points;
- QPointF p_start, p_end;
- qreal ang_start, ang_end;
+ QLineF ax_start, ax_end;
QVector<QLineF> break_axes;
QString text;
int pen_width;
+ QColor color;
- // TODO line width and possibly bus width
void recalc_line();
- void recalc_line_add_point(const QLineF &l1, const QLineF &l2);
+ bool recalc_line_add_point(const QLineF &l1, const QLineF &l2);
+};
+
+class Bus : public Connection {
+public:
+ Bus(const Connector *start, const Connector *end, unsigned width = 4);
+
+ // This creates connector snapped to closes point to x,y that is on bus
+ const Connector *new_connector(qreal x, qreal y, enum Connector::Axis = Connector::AX_X);
+ const Connector *new_connector(const QPointF&, enum Connector::Axis = Connector::AX_X);
+
+protected:
+ struct con_pos {
+ Connector *c;
+ QPointF p;
+ };
+ QVector<struct con_pos> conns;
+ // TODO because of this we have to overload setAxis function and update that in there
+};
+
+class Signal : public Connection {
+public:
+ Signal(const Connector *start, const Connector *end);
};
#define CON_AXIS_X(Y) QLineF(QPointF(0, Y), QPointF(1, Y))