aboutsummaryrefslogtreecommitdiff
path: root/qtmips_gui/coreview/connection.h
blob: efe3942fcc90fe08c2ded856753074bef4da5b69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifndef COREVIEW_CONNECTION_H
#define COREVIEW_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 // COREVIEW_CONNECTION_H