Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
wire.h
Go to the documentation of this file.
1
7
8#ifndef WIRE_H
9#define WIRE_H
10
11#include <QGraphicsItem>
12#include <QPainter>
13#include <math.h>
14
15#include "symbol.h"
16
17class Symbol;
18
21class Wire : public QGraphicsItem {
22public:
28 Wire(Symbol* sourceNode, int port_num_source, Symbol* destNode,
29 int port_num_dest);
30
32 Wire(): arrowSize(10) {
33 setAcceptedMouseButtons(Qt::NoButton);
34 }
35
37 ~Wire() {}
38
42 void setSource(Symbol* destNode, int port){
43 source = destNode;
44 port_num_source = port;
45 }
46
50 void setDestination(Symbol* destNode, int port){
51 dest = destNode;
52 port_num_dest = port;
53 }
54
57 void setColor(QColor Color) {
58 WireColor = Color;
59 }
60
62 void paintWire(){
63 source->addWire(this);
64 dest->addWire(this);
65 adjust();
66 }
67
70 Symbol* sourceNode() const {
71 return source;
72 }
73
76 Symbol* destNode() const{
77 return dest;
78 }
79
81 void adjust();
82
83 enum { Type = UserType + 2 };
84 int type() const { return Type; }
85
86protected:
89 QRectF boundingRect() const;
90
95 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
96 QWidget* widget);
97
98private:
99 Symbol *source, *dest;
100 QColor WireColor;
101 QPointF sourcePoint;
102 QPointF destPoint;
103 qreal arrowSize;
104 int port_num_source;
105 int port_num_dest;
106};
107
108#endif
Abstract base class for schematic symbols.
Definition symbol.h:34
virtual void addWire(Wire *Wire)=0
Add wire connection to symbol.
Wire connection between symbols.
Definition wire.h:21
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Paint wire.
Definition wire.cpp:47
void setDestination(Symbol *destNode, int port)
Set wire destination.
Definition wire.h:50
void paintWire()
Paint wire on scene.
Definition wire.h:62
void adjust()
Adjust wire geometry based on endpoint positions.
Definition wire.cpp:25
void setSource(Symbol *destNode, int port)
Set wire source.
Definition wire.h:42
~Wire()
Class destructor.
Definition wire.h:37
Wire()
Default constructor.
Definition wire.h:32
void setColor(QColor Color)
Set wire color.
Definition wire.h:57
QRectF boundingRect() const
Get wire bounding rectangle.
Definition wire.cpp:41
Symbol * sourceNode() const
Get source symbol.
Definition wire.h:70
Symbol * destNode() const
Get destination symbol.
Definition wire.h:76