Utility functions needed across the whole project.
More...
#include <QFile>
#include <QFileInfo>
#include <QString>
#include <QList>
#include <QPointF>
#include <QRegularExpression>
#include <cmath>
#include <complex>
Go to the source code of this file.
|
| enum | Units {
Capacitance
, Inductance
, Length
, Resistance
,
Degrees
, NoUnits
} |
| | Unit types for engineering values.
|
| |
|
| QString | RoundVariablePrecision (double) |
| | Rounds double to minimum decimal places needed.
|
| |
| QString | num2str (std::complex< double > Z, Units CompType) |
| | Converts complex number to string with units.
|
| |
| QString | num2str (double, Units) |
| | Converts double to string with engineering notation and units.
|
| |
| QString | num2str (double) |
| | Converts double to string with engineering notation.
|
| |
| std::complex< double > | Str2Complex (QString) |
| | Parses string to complex number.
|
| |
| QString | ConvertLengthFromM (QString, double) |
| | Converts length in meters to appropriate unit with auto-scaling.
|
| |
| void | convert_MA_RI_to_dB (double &S_1, double &S_2, double &S_3, double &S_4, QString format) |
| | Converts S-parameter from MA/RI/DB format to dB, angle, real, and imaginary.
|
| |
| double | getFreqScale (QString frequency_unit) |
| | Gets frequency scale factor from unit string.
|
| |
| double | getScaleFactor (QString scale) |
| | Gets scale factor from SI prefix.
|
| |
| int | findClosestIndex (const QList< double > &list, double value) |
| | Finds index of closest value in list.
|
| |
| double | getFreqFromText (QString freq) |
| | Parses frequency string to Hz.
|
| |
| QPointF | findClosestPoint (const QList< double > &xValues, const QList< double > &yValues, double targetX) |
| | Finds closest point in x-y data series.
|
| |
| QMap< QString, QList< double > > | readTouchstoneFile (const QString &filePath) |
| | Reads Touchstone file and extracts S-parameter data.
|
| |
| void | showHTMLDocs (QString path) |
| | Show HTML documentation in the web browser.
|
| |
Utility functions needed across the whole project.
- Author
- Andrés Martínez Mera - andre.nosp@m.smme.nosp@m.ra@pr.nosp@m.oton.nosp@m.mail..nosp@m.com
- Date
- Jan 4, 2026
- Copyright
- Copyright (C) 2026 Andrés Martínez Mera @license GPL-3.0-or-later
◆ convert_MA_RI_to_dB()
| void convert_MA_RI_to_dB |
( |
double & |
S_1, |
|
|
double & |
S_2, |
|
|
double & |
S_3, |
|
|
double & |
S_4, |
|
|
QString |
format |
|
) |
| |
Converts S-parameter from MA/RI/DB format to dB, angle, real, and imaginary.
- Parameters
-
| [in,out] | S_1 | Magnitude (MA), Real (RI), or dB (DB) → dB output |
| [in,out] | S_2 | Angle (MA/DB) or Imaginary (RI) → angle output |
| [out] | S_3 | Real part output |
| [out] | S_4 | Imaginary part output |
| format | Input format: "MA", "RI", or "DB" (case insensitive) |
◆ ConvertLengthFromM()
| QString ConvertLengthFromM |
( |
QString |
units, |
|
|
double |
len |
|
) |
| |
Converts length in meters to appropriate unit with auto-scaling.
- Parameters
-
| units | Current unit (mm, mil, um, nm, inch, ft, m) |
| len | Length in meters |
- Returns
- Formatted string with auto-scaled unit
◆ findClosestIndex()
| int findClosestIndex |
( |
const QList< double > & |
list, |
|
|
double |
value |
|
) |
| |
Finds index of closest value in list.
- Parameters
-
| list | List to search |
| value | Target value |
- Returns
- Index of closest element
◆ findClosestPoint()
| QPointF findClosestPoint |
( |
const QList< double > & |
xValues, |
|
|
const QList< double > & |
yValues, |
|
|
double |
targetX |
|
) |
| |
Finds closest point in x-y data series.
- Parameters
-
| xValues | X-axis values |
| yValues | Y-axis values |
| targetX | Target x value |
- Returns
- Closest point as QPointF
◆ getFreqFromText()
| double getFreqFromText |
( |
QString |
freq | ) |
|
Parses frequency string to Hz.
- Parameters
-
| freq | Frequency string (e.g., "2.4 GHz", "100MHz") |
- Returns
- Frequency in Hz, or -1 if invalid
◆ getFreqScale()
| double getFreqScale |
( |
QString |
frequency_unit | ) |
|
Gets frequency scale factor from unit string.
- Parameters
-
| frequency_unit | Unit string (Hz, kHz, MHz, GHz) |
- Returns
- Scale factor relative to Hz
◆ getScaleFactor()
| double getScaleFactor |
( |
QString |
scale | ) |
|
Gets scale factor from SI prefix.
- Parameters
-
| scale | Prefix string (Y, Z, E, P, T, G, M, k, m, u, n, p, f, a, z, y) |
- Returns
- Scale factor
◆ num2str() [1/3]
| QString num2str |
( |
double |
Num | ) |
|
Converts double to string with engineering notation.
- Parameters
-
- Returns
- Formatted string
◆ num2str() [2/3]
| QString num2str |
( |
double |
Num, |
|
|
Units |
CompType |
|
) |
| |
Converts double to string with engineering notation and units.
- Parameters
-
| Num | Value to convert |
| CompType | Unit type |
- Returns
- Formatted string
◆ num2str() [3/3]
| QString num2str |
( |
std::complex< double > |
Z, |
|
|
Units |
CompType |
|
) |
| |
Converts complex number to string with units.
- Parameters
-
| Z | Complex value |
| CompType | Unit type |
- Returns
- Formatted string
◆ readTouchstoneFile()
| QMap< QString, QList< double > > readTouchstoneFile |
( |
const QString & |
filePath | ) |
|
Reads Touchstone file and extracts S-parameter data.
- Parameters
-
| filePath | Path to the Touchstone file (.sNp) |
- Returns
- Map of variable names to data arrays
◆ RoundVariablePrecision()
| QString RoundVariablePrecision |
( |
double |
val | ) |
|
Rounds double to minimum decimal places needed.
- Parameters
-
- Returns
- Formatted string
◆ showHTMLDocs()
| void showHTMLDocs |
( |
QString |
path | ) |
|
Show HTML documentation in the web browser.
- Parameters
-
| path | Path to the HTML file |
◆ Str2Complex()
| std::complex< double > Str2Complex |
( |
QString |
num | ) |
|
Parses string to complex number.
- Parameters
-
| num | String representation (e.g., "50+j25", "j50", "50") |
- Returns
- Complex number