aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview/connection.h
diff options
context:
space:
mode:
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))