Subversion Repositories Code-Repo

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
335 Kevin 1
#ifndef WIRE_H
2
#define WIRE_H
3
 
4
#include "GlobalDefines.h"
5
#include "Gate_BASE.h"
6
 
7
#define SELECTION_WIDTH 10
8
 
9
class Gate_BASE;
10
class Canvas;
11
 
12
class Wire : public QGraphicsObject
13
{
14
    Q_OBJECT
15
    public:
16
        Wire(QGraphicsItem *parent = 0);
17
        ~Wire();
18
 
19
        QRectF boundingRect() const;
20
        QPainterPath shape() const;
21
        void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
22
 
23
        void setPoints(Gate_BASE *source, Gate_BASE *sink, int sinkID);
24
        void setPenColor(QColor color);
25
        void setHighlight(bool state, QColor color);
26
 
27
        void setValue(logicValue value, logicValue faultyValue, bool recurse = true);
28
 
29
        Gate_BASE *gateOutput;
30
        Gate_BASE *gateInput;
31
        int gateInputID;
32
 
33
        logicValue wireValue;
34
        logicValue wireFaultyValue;
35
 
36
    signals:
37
        void updateStatus(QString status);
38
 
39
    public slots:
40
        void promptValue();
41
        void promptFaultyValue();
42
        void reset();
43
        void toggleShowValues();
44
 
45
    protected:
46
        virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
47
        virtual void contextMenuEvent(QGraphicsSceneContextMenuEvent *event);
48
 
49
    private:
50
        void createActions();
51
        QAction *injectValueAction;
52
        QAction *injectFaultAction;
53
        QAction *resetValuesAction;
54
 
55
        QString valueString;
56
 
57
        bool auxSelected;
58
        bool showValues;
59
 
60
        QPen defaultPen;
61
        QBrush defaultBrush;
62
 
63
        QPen selectedPen;
64
        QPen highlightedPen;
65
 
66
        QFont defaultFont;
67
        QRectF textRect;
68
 
69
        QRectF bRect;
70
        QPainterPath shapeArea;
71
        QPainterPath line;
72
        QList<QPointF> linePoints;
73
 
74
#ifdef _DEBUG
75
        QPen debugPen;
76
        QBrush debugBrush;
77
        QPen debugSelectedPen;
78
        QPen debugErrorPen;
79
#endif
80
};
81
 
82
#endif // WIRE_H