Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
component.h
Go to the documentation of this file.
1
7
8#ifndef COMPONENT_H
9#define COMPONENT_H
10
11#include <QGraphicsItem>
12#include <QGraphicsScene>
13#include <QGraphicsSceneMouseEvent>
14#include <QGraphicsView>
15#include <QList>
16#include <QPainter>
17#include <QStyleOption>
18#include <cmath>
19#include <qdebug.h>
20
21#include "Misc/general.h"
22#include "graphwidget.h"
23#include "infoclasses.h"
24#include "structures.h"
25#include "symbol.h"
26#include "wire.h"
27
28class Wire;
29
30
33class Component : public Symbol {
34 Q_OBJECT
35public:
36
43 Component(GraphWidget* graphWidget, ComponentType, double,
44 QMap<QString, QString>, QString ID);
45
49 Component(GraphWidget* graphWidget, struct ComponentInfo);
50
51
54
57 void addWire(Wire* Wire);
58
61 QList<Wire*> Wires() const { return WireList; }
62
63 enum { Type = UserType + 1 };
64 int type() const { return Type; }
65
68 QRectF boundingRect() const;
69
72 QPainterPath shape() const;
73
78 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
79 QWidget* widget);
80
84 QPoint getPortLocation(int);
85
88 QString getID() { return ID; }
89
92 void setRotation(double R) { Rotation = R; }
93
97 void setParameters(QMap<QString, QString> val) { Value = val; }
98
101 QMap<QString, QString> getParameters() { return Value; }
102
105 void setComponentType(ComponentType CT) { CompType = CT; }
106
109 ComponentType getComponentType() { return CompType; }
110
111protected:
113 QVariant itemChange(GraphicsItemChange change, const QVariant& value);
114
116 void mousePressEvent(QGraphicsSceneMouseEvent* event) {
117 update();
118 QGraphicsItem::mousePressEvent(event);
119 }
120
122 void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) {
123 update();
124 QGraphicsItem::mouseReleaseEvent(event);
125 }
126
128 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
129
130private:
131 QList<Wire*> WireList;
132 QPointF newPos;
133 GraphWidget* graph;
134 ComponentType CompType;
135 double Rotation;
136 QMap<QString, QString> Value;
137 QString ID;
138
141 void RotatePoint(QPoint&);
142
146 void RotatePoint(QPoint&, double);
147
150 void paintCapacitor(QPainter*);
151 void paintInductor(QPainter*);
152 void paintTransmissionLine(QPainter*);
153 void paintResistor(QPainter*);
154 void paintComplexImpedance(QPainter*);
155 void paintTerm(QPainter*);
156 void paintGND(QPainter*);
157 void paintOpenStub(QPainter*);
158 void paintShortStub(QPainter*);
159 void paintCoupledLines(QPainter*);
160 void paintCoupler(QPainter*);
161 void paintSPAR(QPainter*);
162
163 // Microstrip components
164 void paintMicrostripLine(QPainter*);
165 void paintMicrostripStep(QPainter*);
166 void paintMicrostripOpen(QPainter*);
167 void paintMicrostripVia(QPainter*);
168 void paintMicrostripCoupledLines(QPainter*);
170signals:
174};
175#endif
Component information container.
Definition infoclasses.h:18
Graphical component representation in schematic.
Definition component.h:33
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
Handle mouse release events.
Definition component.h:122
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
Handle double click events.
Definition component.cpp:211
QRectF boundingRect() const
Get component bounding rectangle.
Definition component.cpp:42
QMap< QString, QString > getParameters()
Get component parameters.
Definition component.h:101
QString getID()
Get component identifier.
Definition component.h:88
void setComponentType(ComponentType CT)
Set component type.
Definition component.h:105
void DoubleClicked(struct ComponentInfo)
Emitted when component is double-clicked.
void addWire(Wire *Wire)
Add wire connection to component.
Definition component.cpp:37
ComponentType getComponentType()
Get component type.
Definition component.h:109
QPainterPath shape() const
Get component selection shape.
Definition component.cpp:88
QList< Wire * > Wires() const
Get list of connected wires to this component.
Definition component.h:61
QVariant itemChange(GraphicsItemChange change, const QVariant &value)
Handle item change events.
Definition component.cpp:195
void mousePressEvent(QGraphicsSceneMouseEvent *event)
Handle mouse press events.
Definition component.h:116
~Component()
Class destructor.
Definition component.h:53
void setParameters(QMap< QString, QString > val)
Set component parameters.
Definition component.h:97
QPoint getPortLocation(int)
Get port location in component coordinates.
Definition component.cpp:222
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
Paint component on scene.
Definition component.cpp:119
void setRotation(double R)
Set component rotation angle.
Definition component.h:92
Definition graphwidget.h:28
Abstract base class for schematic symbols.
Definition symbol.h:34
Wire connection between symbols.
Definition wire.h:21
Utility functions needed across the whole project.
Definition of the classes related to the component, nodes and wires data.
Wire connection between symbols (definition)