Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
infoclasses.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 INFOCLASSES_H
19#define INFOCLASSES_H
20#include "../Schematic/structures.h"
21#include <QColor>
22#include <QFont>
23#include <QMap>
24#include <QPointF>
25
27public:
28 ComponentInfo() : Coordinates(2) {}
29
30 ComponentInfo(QString ID_, ComponentType Type_, double rot_, double x,
31 double y)
32 : ID(ID_), Type(Type_), Rotation(rot_), Coordinates(2) {
33 Coordinates[0] = x;
34 Coordinates[1] = y;
35 }
36
37 ComponentInfo(QString ID_, ComponentType Type_, double rot_, QPoint P)
38 : ID(ID_), Type(Type_), Rotation(rot_), Coordinates(2) {
39 Coordinates[0] = P.x();
40 Coordinates[1] = P.y();
41 }
42
43 ComponentInfo(QString ID_, ComponentType Type_, QPoint P)
44 : ID(ID_), Type(Type_), Coordinates(2) {
45 Coordinates[0] = P.x();
46 Coordinates[1] = P.y();
47 Rotation = 0;
48 }
49
51
52 QString ID;
53 ComponentType Type;
54 double Rotation;
55 QString Net1, Net2; // ID of the nodes where the component is connected
56 std::vector<double> Coordinates;
57 int getNumberOfPorts() const {
58 switch (Type) {
59 case MicrostripCoupledLines:
60 case CoupledLines:
61 case Coupler:
62 return 4;
63 default:
64 return 2;
65 }
66 }
67
68 void setParams(QString ID_, ComponentType Type_, double Rotation_, double x,
69 double y // Coordinates
70 ) {
71 ID = ID_;
72 Type = Type_;
73 Rotation = Rotation_;
74 Coordinates[0] = x;
75 Coordinates[1] = y;
76 }
77
78 void setParams(QString ID_, ComponentType Type_, double Rotation_, QPoint P) // Coordinates
79 {
80 ID = ID_;
81 Type = Type_;
82 Rotation = Rotation_;
83 Coordinates[0] = P.x();
84 Coordinates[1] = P.y();
85 }
86
87 void setParams(QString ID_, ComponentType Type_, QPoint P) // Coordinates
88 {
89 ID = ID_;
90 Type = Type_;
91 Rotation = 0;
92 Coordinates[0] = P.x();
93 Coordinates[1] = P.y();
94 }
95
96 QMap<QString, QString> val; // freq, L1.L, C1.C,...
97 double getVal(QString);
98};
99
100class WireInfo {
101public:
102 WireInfo() {}
103 ~WireInfo() {}
104 WireInfo(QString O, int OP, QString D, int DP)
105 : OriginID(O), PortOrigin(OP), DestinationID(D), PortDestination(DP) {}
106 void setParams(QString O, int OP, QString D, int DP) {
107 OriginID = O, DestinationID = D;
108 PortOrigin = OP, PortDestination = DP;
109 WireColor = Qt::black;
110 }
111 void setParams(QString O, int OP, QString D, int DP, QColor Color) {
112 OriginID = O, DestinationID = D;
113 PortOrigin = OP, PortDestination = DP;
114 WireColor = Color;
115 }
116 void setID(QString id) { ID = id; }
117 QString getID() { return ID; }
118
119 void setNet(QString net) { Net = net; }
120 QString getNet() { return Net; }
121
122 QString OriginID;
123 int PortOrigin;
124 QString DestinationID;
125 int PortDestination;
126 QColor WireColor;
127
128 QString ID;
129
130private:
131 QString Net;
132};
133
134class NodeInfo {
135public:
136 NodeInfo() : Coordinates(2) {}
137 ~NodeInfo() {}
138 NodeInfo(QString ID_, double x, double y) : ID(ID_), Coordinates(2) {
139 Coordinates[0] = x;
140 Coordinates[1] = y;
141 }
142
143 NodeInfo(QString ID_, QPoint P) : ID(ID_), Coordinates(2) {
144 Coordinates[0] = P.x();
145 Coordinates[1] = P.y();
146 }
147
148
149 void setParams(QString ID_, double x, double y) {
150 ID = ID_;
151 Coordinates[0] = x;
152 Coordinates[1] = y;
153 }
154
155 void setParams(QString ID_, QPoint P) {
156 ID = ID_;
157 Coordinates[0] = P.x();
158 Coordinates[1] = P.y();
159 }
160
161 QString ID;
162 QString Net;
163 std::vector<double> Coordinates;
164 bool visible = true;
165};
166
167class TextInfo {
168public:
169 TextInfo() : position(0, 0) {}
170
171 TextInfo(QString ID_, QString text_, QFont font_ = QFont(),
172 QColor color_ = Qt::black, QPointF position_ = QPointF())
173 : ID(ID_), text(text_), font(font_), color(color_), position(position_) {}
174
175 void setParams(QString ID_, QString text_, QFont font_ = QFont(),
176 QColor color_ = Qt::black, QPointF position_ = QPointF()) {
177 ID = ID_;
178 text = text_;
179 font = font_;
180 color = color_;
181 position = position_;
182 }
183
184 QString ID;
185 QString text;
186 QFont font;
187 QColor color;
188 QPointF position;
189};
190
191#endif // INFOCLASSES_H
Definition infoclasses.h:26
Definition infoclasses.h:134
Definition infoclasses.h:167
Definition infoclasses.h:100