Merge branch 'master' of github.com:jankae/LibreVNA

This commit is contained in:
Jan Käberich 2022-03-28 22:07:20 +02:00
commit ea6fdac2a4
49 changed files with 637 additions and 348 deletions

View file

@ -81,6 +81,11 @@ static void createLogarithmicTicks(vector<double>& ticks, double start, double s
} while(div <= stop);
}
YAxis::YAxis()
{
type = Type::Magnitude;
}
double YAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample)
{
switch(type) {
@ -104,11 +109,11 @@ double YAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample
case YAxis::Type::Imaginary:
return data.y.imag();
case YAxis::Type::SeriesR:
return Util::SparamToResistance(data.y);
return Util::SparamToResistance(data.y, t->getReferenceImpedance());
case YAxis::Type::Reactance:
return Util::SparamToImpedance(data.y).imag();
return Util::SparamToImpedance(data.y, t->getReferenceImpedance()).imag();
case YAxis::Type::Capacitance:
return Util::SparamToCapacitance(data.y, data.x);
return Util::SparamToCapacitance(data.y, data.x, t->getReferenceImpedance());
case YAxis::Type::Inductance:
return Util::SparamToInductance(data.y, data.x);
case YAxis::Type::QualityFactor:
@ -159,7 +164,7 @@ double YAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample
}
double step = t->sample(sample, true).y.real();
if(abs(step) < 1.0) {
return Util::SparamToImpedance(step).real();
return Util::SparamToImpedance(step, t->getReferenceImpedance()).real();
}
}
break;
@ -246,7 +251,7 @@ QString YAxis::Unit(Type type, TraceModel::DataSource source)
case Type::Reactance: return "Ω";
case Type::Capacitance: return "F";
case Type::Inductance: return "H";
case Type::Last: return "";
default: return "";
}
} else if(source == TraceModel::DataSource::SA) {
switch(type) {
@ -280,7 +285,7 @@ QString YAxis::Prefixes(Type type, TraceModel::DataSource source)
case Type::Reactance: return "m kM";
case Type::Capacitance: return "pnum ";
case Type::Inductance: return "pnum ";
case Type::Last: return " ";
default: return " ";
}
} else if(source == TraceModel::DataSource::SA) {
switch(type) {
@ -358,8 +363,14 @@ bool Axis::getLog() const
return log;
}
XAxis::XAxis()
{
type = Type::Frequency;
}
double XAxis::sampleToCoordinate(Trace::Data data, Trace *t, unsigned int sample)
{
Q_UNUSED(sample)
switch(type) {
case Type::Distance:
if(!t) {
@ -430,6 +441,16 @@ XAxis::Type XAxis::getType() const
return type;
}
Axis::Axis()
{
log = false;
autorange = true;
rangeMin = -1.0;
rangeMax = 1.0;
rangeDiv = 1.0;
ticks.clear();
}
double Axis::transform(double value, double to_low, double to_high)
{
return Util::Scale(value, rangeMin, rangeMax, to_low, to_high, log);