Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
component.h
1/*
2 * Copyright (C) 2019-2025 Andrés Martínez Mera - andresmmera@protonmail.com
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17
18#ifndef COMPONENT_H
19#define COMPONENT_H
20
21#include <QGraphicsItem>
22#include <QGraphicsScene>
23#include <QGraphicsSceneMouseEvent>
24#include <QGraphicsView>
25#include <QList>
26#include <QPainter>
27#include <QStyleOption>
28#include <cmath>
29#include <qdebug.h>
30
31#include "../Misc/general.h"
32#include "graphwidget.h"
33#include "infoclasses.h"
34#include "structures.h"
35#include "symbol.h"
36#include "wire.h"
37
38class Wire;
39
40class Component : public Symbol {
41 Q_OBJECT
42public:
43 Component(GraphWidget* graphWidget, ComponentType, double,
44 QMap<QString, QString>, QString ID);
45 Component(GraphWidget* graphWidget, struct ComponentInfo);
46 ~Component();
47 void addWire(Wire* Wire);
48 QList<Wire*> Wires() const;
49
50 enum { Type = UserType + 1 };
51 int type() const { return Type; }
52
53 QRectF boundingRect() const;
54 QPainterPath shape() const;
55 void paint(QPainter* painter, const QStyleOptionGraphicsItem* option,
56 QWidget* widget);
57 QPoint getPortLocation(int);
58 QString getID();
59 void setRotation(double);
60 void setParameters(QMap<QString, QString>);
61 QMap<QString, QString> getParameters();
62 void setComponentType(ComponentType);
63 ComponentType getComponentType();
64
65protected:
66 QVariant itemChange(GraphicsItemChange change, const QVariant& value);
67
68 void mousePressEvent(QGraphicsSceneMouseEvent* event);
69 void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
70 void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event);
71
72private:
73 QList<Wire*> WireList;
74 QPointF newPos;
75 GraphWidget* graph;
76 ComponentType CompType;
77 double Rotation;
78 QMap<QString, QString> Value;
79 QString ID;
80
81 void RotatePoint(QPoint&);
82 void RotatePoint(QPoint&, double);
83
84 // Component symbol code
85 void paintCapacitor(QPainter*);
86 void paintInductor(QPainter*);
87 void paintTransmissionLine(QPainter*);
88 void paintResistor(QPainter*);
89 void paintComplexImpedance(QPainter*);
90 void paintTerm(QPainter*);
91 void paintGND(QPainter*);
92 void paintOpenStub(QPainter*);
93 void paintShortStub(QPainter*);
94 void paintCoupledLines(QPainter*);
95 void paintCoupler(QPainter*);
96 void paintSPAR(QPainter*);
97
98 // Microstrip components
99 void paintMicrostripLine(QPainter*);
100 void paintMicrostripStep(QPainter*);
101 void paintMicrostripOpen(QPainter*);
102 void paintMicrostripVia(QPainter*);
103 void paintMicrostripCoupledLines(QPainter*);
104
105signals:
106 void DoubleClicked(struct ComponentInfo);
107};
108#endif
Definition infoclasses.h:26
Definition component.h:40
[0]
Definition graphwidget.h:60
Definition symbol.h:31
[0]
Definition wire.h:30