diff options
author | Karel Kočí <cynerd@email.cz> | 2017-12-15 22:45:28 +0100 |
---|---|---|
committer | Karel Kočí <cynerd@email.cz> | 2017-12-15 22:45:28 +0100 |
commit | e6ca4b4568e311b47239bfe83de15ed9e91c57b9 (patch) | |
tree | 3da2f72faf360058bae02c35b0c724233bd64d61 /qtmips_gui/coreview/connection.h | |
parent | bbea996112eb7ac81ec50d2af08f4bd681d0e50d (diff) | |
download | qtmips-e6ca4b4568e311b47239bfe83de15ed9e91c57b9.tar.gz qtmips-e6ca4b4568e311b47239bfe83de15ed9e91c57b9.tar.bz2 qtmips-e6ca4b4568e311b47239bfe83de15ed9e91c57b9.zip |
Implement few initial graphic elements
Diffstat (limited to 'qtmips_gui/coreview/connection.h')
-rw-r--r-- | qtmips_gui/coreview/connection.h | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/qtmips_gui/coreview/connection.h b/qtmips_gui/coreview/connection.h new file mode 100644 index 0000000..eda6afe --- /dev/null +++ b/qtmips_gui/coreview/connection.h @@ -0,0 +1,60 @@ +#ifndef CONNECTION_H +#define CONNECTION_H + +#include <QGraphicsObject> +#include <QList> +#include <cmath> +#include "../coreview.h" + +namespace coreview { + +class Connector : public QObject { + Q_OBJECT +public: + void setPos(qreal x, qreal y); + qreal x() const; + qreal y() const; + QPointF point() const; + +signals: + void updated(); + +private: + qreal qx, qy; +}; + +class Connection : public QGraphicsObject { + Q_OBJECT +public: + Connection(const Connector *a, const Connector *b); + + void setHasText(bool has); + void setText(QString val); + +private slots: + void moved(); + +private: + QGraphicsSimpleTextItem *value; + QList<QPointF> points; + const Connector *a, *b; + QString text; + + QRectF boundingRect() const; + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + + // TODO line width and possibly bus width + + void update_pos(); +}; + +} + +#else + +namespace coreview { + class Connector; + class Connection; +}; + +#endif // CONNECTION_H |