Qucs-S S-parameter Viewer & RF Synthesis Tools
Loading...
Searching...
No Matches
LoadSpecificationWidget.h
Go to the documentation of this file.
1
7
8#ifndef LOADSPECIFICATIONWIDGET_H
9#define LOADSPECIFICATIONWIDGET_H
10
11#include <QButtonGroup>
12#include <QCheckBox>
13#include <QComboBox>
14#include <QDoubleSpinBox>
15#include <QFileDialog>
16#include <QFileInfo>
17#include <QGridLayout>
18#include <QGroupBox>
19#include <QHBoxLayout>
20#include <QLabel>
21#include <QMessageBox>
22#include <QMouseEvent>
23#include <QPushButton>
24#include <QRadioButton>
25#include <QTextStream>
26#include <QVBoxLayout>
27#include <QWidget>
28#include <cmath>
29#include <complex>
30
31#include "Misc/general.h"
32
35class LoadSpecificationWidget : public QGroupBox {
36 Q_OBJECT
37
38public:
41 explicit LoadSpecificationWidget(QWidget* parent = nullptr);
42
45
48
51 std::array<std::complex<double>, 4> getSParameters() const {
52 return {getS11(), getS12(), getS21(), getS22()};
53 }
54
57 std::complex<double> getLoadImpedance_At_Fmatch() const;
58
61 QList<std::complex<double>> getZLdata();
62
65 QList<double> getFrequency();
66
69 std::pair<std::complex<double>, std::complex<double>>
71
74 std::complex<double> getReflectionCoefficient() const;
75
78 QString getSparFilePath() { return spar_file_path; }
79
82 bool isTwoPortMode() const { return m_twoPortMode; }
84
90 std::complex<double> getS11() const;
91
94 std::complex<double> getS12() const;
95
98 std::complex<double> getS21() const;
99
102 std::complex<double> getS22() const;
104
107
110 void setLoadImpedance(const std::complex<double>& impedance);
111
114 void setReflectionCoefficient(const std::complex<double>& gamma);
115
118 void setTwoPortMode(bool enabled);
119
122 void setReferenceImpedance(double Z0) {
123 m_Z0 = Z0;
124 updateReflectionCoefficient();
125 }
126
129 void setCollapsed(bool collapsed);
130
133 void setFmatch(double freq) { f_match = freq; }
134
137 bool isCollapsed() const { return m_isCollapsed; }
138
139 // Reference impedance of the source and the load port. Required for the
140 // 2-port matching. This data is provided by the main widget
141 double Z0_Port1, Z0_Port2;
142
143protected:
146 void mousePressEvent(QMouseEvent* event) override;
147
148private slots:
150 void onImpedanceChanged();
151
153 void onReflectionCoefficientChanged();
154
156 void onFormatChanged();
157
159 void onInputMethodChanged();
160
162 void onBrowseFile();
163
165 void onSParameterChanged();
166
168 void onToggleCollapse() {
169 setCollapsed(!m_isCollapsed);
170 }
171
172
173private:
175 void setupUI();
176
178 void setupOnePortUI();
179
181 void setupTwoPortUI();
182
184 void updateReflectionCoefficient();
185
187 void updateImpedance();
188
190 void updateSParameterDisplays();
191
193 void updateImpedanceFormat();
194
196 void updateReflectionFormat();
197
199 void updateSParameterFormat();
200
201 double f_match;
202
203 QMap<QString, QList<double>> loadData;
204 QString spar_file_path;
205
208 QGridLayout* m_mainLayout;
209 QWidget* m_contentWidget;
210 QPushButton* m_toggleButton;
212
215 QRadioButton* m_manualInputRadio;
216 QRadioButton* m_fileInputRadio;
217 QButtonGroup* m_inputMethodGroup;
218 QPushButton* m_browseButton;
219 QLabel* m_fileLabel;
221
224 QLabel* m_formatLabel;
225 QComboBox* m_formatCombo;
227
230 QLabel* m_impedanceLabel;
231 QDoubleSpinBox* m_impedanceReal;
232 QLabel* m_impedanceSeparator;
233 QDoubleSpinBox* m_impedanceImag;
234 QLabel* m_impedanceUnit;
236
239 QLabel* m_reflectionLabel;
240 QDoubleSpinBox* m_reflectionReal;
241 QLabel* m_reflectionSeparator;
242 QDoubleSpinBox* m_reflectionImag;
244
247 QWidget* m_twoPortWidget;
248 QGridLayout* m_twoPortLayout;
250
253 QLabel* m_s11Label;
254 QDoubleSpinBox* m_s11Real;
255 QLabel* m_s11Separator;
256 QDoubleSpinBox* m_s11Imag;
257
258 QLabel* m_s12Label;
259 QDoubleSpinBox* m_s12Real;
260 QLabel* m_s12Separator;
261 QDoubleSpinBox* m_s12Imag;
262
263 QLabel* m_s21Label;
264 QDoubleSpinBox* m_s21Real;
265 QLabel* m_s21Separator;
266 QDoubleSpinBox* m_s21Imag;
267
268 QLabel* m_s22Label;
269 QDoubleSpinBox* m_s22Real;
270 QLabel* m_s22Separator;
271 QDoubleSpinBox* m_s22Imag;
273
276 bool m_twoPortMode;
277 bool m_updatingValues;
278 bool m_isCollapsed;
279 double m_Z0;
280 QString m_currentFile;
282
283signals:
286
289
292
295 void collapsedStateChanged(bool collapsed);
296};
297
298#endif // LOADSPECIFICATIONWIDGET_H
Widget for entering the load impedance data.
Definition LoadSpecificationWidget.h:35
std::complex< double > getReflectionCoefficient() const
Get reflection coefficient.
Definition LoadSpecificationWidget.cpp:336
std::complex< double > getLoadImpedance_At_Fmatch() const
Get load impedance at matching frequency.
Definition LoadSpecificationWidget.cpp:257
void sParametersChanged()
Emitted when S-parameters change.
std::complex< double > getS22() const
Get S22 parameter.
Definition LoadSpecificationWidget.cpp:377
void reflectionCoefficientChanged()
Emitted when reflection coefficient changes.
void setTwoPortMode(bool enabled)
Enable or disable two-port mode.
Definition LoadSpecificationWidget.cpp:423
QList< std::complex< double > > getZLdata()
Get load impedance data over frequency.
Definition LoadSpecificationWidget.cpp:268
std::array< std::complex< double >, 4 > getSParameters() const
Get all S-parameters as an array [S11, S12, S21, S22].
Definition LoadSpecificationWidget.h:51
void setCollapsed(bool collapsed)
Set collapsed state of widget.
Definition LoadSpecificationWidget.cpp:789
QString getSparFilePath()
Get S-parameter file path.
Definition LoadSpecificationWidget.h:78
void setReflectionCoefficient(const std::complex< double > &gamma)
Set reflection coefficient.
Definition LoadSpecificationWidget.cpp:405
QList< double > getFrequency()
Get frequency data points.
Definition LoadSpecificationWidget.cpp:279
std::complex< double > getS12() const
Get S12 parameter.
Definition LoadSpecificationWidget.cpp:357
~LoadSpecificationWidget()
Class destructor.
Definition LoadSpecificationWidget.h:44
void impedanceChanged()
Emitted when impedance value changes.
void setReferenceImpedance(double Z0)
Set reference impedance.
Definition LoadSpecificationWidget.h:122
std::pair< std::complex< double >, std::complex< double > > getTwoPortMatchingImpedances() const
Calculate two-port matching impedances (source and load)
Definition LoadSpecificationWidget.cpp:284
void setLoadImpedance(const std::complex< double > &impedance)
Set load impedance.
Definition LoadSpecificationWidget.cpp:387
void mousePressEvent(QMouseEvent *event) override
Handle mouse press events for collapsible header.
Definition LoadSpecificationWidget.cpp:807
std::complex< double > getS21() const
Get S21 parameter.
Definition LoadSpecificationWidget.cpp:367
void setFmatch(double freq)
Set matching frequency.
Definition LoadSpecificationWidget.h:133
bool isTwoPortMode() const
Check if widget is in two-port mode.
Definition LoadSpecificationWidget.h:82
bool isCollapsed() const
Check if widget is collapsed.
Definition LoadSpecificationWidget.h:137
void collapsedStateChanged(bool collapsed)
Emitted when collapsed state changes.
Utility functions needed across the whole project.