From 506174a8266eb9842ff9e50a89ddf86cb975be30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Mon, 8 Jan 2018 21:43:58 +0100 Subject: Add coreview progress --- qtmips_gui/coreview/connection.h | 46 +++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'qtmips_gui/coreview/connection.h') diff --git a/qtmips_gui/coreview/connection.h b/qtmips_gui/coreview/connection.h index efe3942..0ee981e 100644 --- a/qtmips_gui/coreview/connection.h +++ b/qtmips_gui/coreview/connection.h @@ -2,59 +2,67 @@ #define COREVIEW_CONNECTION_H #include -#include -#include -#include "../coreview.h" +#include +#include namespace coreview { class Connector : public QObject { Q_OBJECT public: + Connector(qreal angle); + void setPos(qreal x, qreal y); qreal x() const; qreal y() const; QPointF point() const; + QLineF vector() const; + + qreal angle() const; signals: - void updated(); + void updated(QPointF); private: + qreal ang; qreal qx, qy; }; class Connection : public QGraphicsObject { Q_OBJECT public: - Connection(const Connector *a, const Connector *b); + Connection(const Connector *start, const Connector *end); + + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); void setHasText(bool has); void setText(QString val); + void setAxes(QVector); + private slots: - void moved(); + void moved_start(QPointF); + void moved_end(QPointF); private: QGraphicsSimpleTextItem *value; - QList points; - const Connector *a, *b; + QVector points; + QPointF p_start, p_end; + qreal ang_start, ang_end; + QVector break_axes; QString text; - QRectF boundingRect() const; - void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + int pen_width; // TODO line width and possibly bus width - - void update_pos(); + void recalc_line(); + void recalc_line_add_point(const QLineF &l1, const QLineF &l2); }; -} - -#else +#define CON_AXIS_X(Y) QLineF(QPointF(0, Y), QPointF(1, Y)) +#define CON_AXIS_Y(X) QLineF(QPointF(X, 0), QPointF(X, 1)) -namespace coreview { - class Connector; - class Connection; -}; +} #endif // COREVIEW_CONNECTION_H -- cgit v1.2.3