Move schematic drawing functions to Filter class

getLineString(), getTeeString(), and getWireString() were recently created inside the QuarterWave_Filter class. The purpose of these functions is to ease the schematic generation code and they could be used in other filter implementations. It makes more sense to put them in a more general class, such as the Filter class.
This commit is contained in:
andresmmera 2024-05-31 19:28:59 +02:00
parent bb7b9fa3c9
commit 3f8b53556b
4 changed files with 31 additions and 30 deletions

View File

@ -350,3 +350,30 @@ double Filter::quadraticChebyshevValues(int No, int Order, double Ripple, double
a *= 2.0 * b * sinh(c);
return a;
}
// SCHEMATIC DRAWING FUNCTIONS
QString Filter::getLineString(bool isMicrostrip, double width_or_impedance, double l, int x, int y, int rotate)
{
if (isMicrostrip)
{
return QString("<MLIN MS1 1 %1 %2 26 -30 0 %3 \"Sub1\" 1 \"%4mm\" 1 \"%5mm\" 1 \"Hammerstad\" 0 \"Kirschning\" 0 \"26.85\" 0>\n")
.arg(x).arg(y).arg(rotate).arg(width_or_impedance*1000).arg(l*1000);
}
else
{
return QString("<TLIN Line1 1 %1 %2 -26 20 0 %3 \"%4\" 1 \"%5\" 1 \"0 dB\" 0 \"26.85\" 0>\n")
.arg(x).arg(y).arg(rotate).arg(width_or_impedance).arg(l);
}
}
QString Filter::getWireString(int x1, int y1, int x2, int y2)
{
return QString("<%1 %2 %3 %4 \"\" 0 0 0>\n").arg(x1).arg(y1).arg(x2).arg(y2);
}
QString Filter::getTeeString(int x, int y, double width1, double width2, double width3)
{
return QString("<MTEE MS1 1 %1 %2 -26 20 1 0 \"Sub1\" 1 \"%3mm\" 1 \"%4mm\" 1 \"%5mm\" 1 \"Hammerstad\" 0 \"Kirschning\" 0 \"26.85\" 0>\n")
.arg(x).arg(y).arg(width1*1000).arg(width2*1000).arg(width3*1000);
}

View File

@ -65,6 +65,10 @@ public:
static double getNormValue(int, tFilter*);
static double getQuadraticNormValues(int, tFilter*, double&);
static QString getLineString(bool isMicrostrip, double width_or_impedance, double l, int x, int y, int rotate=0);
static QString getTeeString(int x, int y, double width1, double width2, double width3);
static QString getWireString(int x1, int x2, int x3, int x4);
protected:
static QString num2str(double);
static double getE6value(double);

View File

@ -38,31 +38,6 @@ QuarterWave_Filter::QuarterWave_Filter()
{
}
QString QuarterWave_Filter::getLineString(bool isMicrostrip, double width_or_impedance, double l, int x, int y, int rotate)
{
if (isMicrostrip)
{
return QString("<MLIN MS1 1 %1 %2 26 -30 0 %3 \"Sub1\" 1 \"%4mm\" 1 \"%5mm\" 1 \"Hammerstad\" 0 \"Kirschning\" 0 \"26.85\" 0>\n")
.arg(x).arg(y).arg(rotate).arg(width_or_impedance*1000).arg(l*1000);
}
else
{
return QString("<TLIN Line1 1 %1 %2 -26 20 0 %3 \"%4\" 1 \"%5\" 1 \"0 dB\" 0 \"26.85\" 0>\n")
.arg(x).arg(y).arg(rotate).arg(width_or_impedance).arg(l);
}
}
QString QuarterWave_Filter::getWireString(int x1, int y1, int x2, int y2)
{
return QString("<%1 %2 %3 %4 \"\" 0 0 0>\n").arg(x1).arg(y1).arg(x2).arg(y2);
}
QString QuarterWave_Filter::getTeeString(int x, int y, double width1, double width2, double width3)
{
return QString("<MTEE MS1 1 %1 %2 -26 20 1 0 \"Sub1\" 1 \"%3mm\" 1 \"%4mm\" 1 \"%5mm\" 1 \"Hammerstad\" 0 \"Kirschning\" 0 \"26.85\" 0>\n")
.arg(x).arg(y).arg(width1*1000).arg(width2*1000).arg(width3*1000);
}
// -----------------------------------------------------------------------
QString *QuarterWave_Filter::createSchematic(tFilter *Filter, tSubstrate *Substrate, bool isMicrostrip)
{

View File

@ -23,7 +23,6 @@
#ifndef QUARTERWAVE_FILTER_H
#define QUARTERWAVE_FILTER_H
#include "tl_filter.h"
// Quarter wave transmission line filter
@ -37,10 +36,6 @@ public:
QuarterWave_Filter();
static QString* createSchematic(tFilter*, tSubstrate*, bool);
static QString getLineString(bool isMicrostrip, double width_or_impedance, double l, int x, int y, int rotate=0);
static QString getTeeString(int x, int y, double width1, double width2, double width3);
static QString getWireString(int x1, int x2, int x3, int x4);
};
#endif