Merge branch 'jankae:master' into sweep_standby

This commit is contained in:
Andre Dunford 2022-12-17 00:40:14 -08:00 committed by GitHub
commit 9a23938180
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 95 additions and 42 deletions

View File

@ -136,7 +136,7 @@ QString Marker::formatToString(Marker::Format f)
case Format::CenterBandwidth: return "Center + Bandwidth";
case Format::InsertionLoss: return "Insertion loss";
case Format::P1dB: return "P1dB";
case Format::NonUniformity: return "Non-uniformity";
case Format::Flatness: return "Flatness";
case Format::maxDeltaNeg: return "Max. Delta Negative";
case Format::maxDeltaPos: return "Max. Delta Positive";
case Format::Last: return "";
@ -265,8 +265,8 @@ std::vector<Marker::Format> Marker::applicableFormats()
ret.push_back(Format::AvgTone);
ret.push_back(Format::AvgModulationProduct);
break;
case Type::NonUniformity:
ret.push_back(Format::NonUniformity);
case Type::Flatness:
ret.push_back(Format::Flatness);
ret.push_back(Format::maxDeltaNeg);
ret.push_back(Format::maxDeltaPos);
break;
@ -371,8 +371,8 @@ std::vector<Marker::Format> Marker::defaultActiveFormats()
if(pref.Marker.defaultBehavior.showP1dB) {
ret.push_back(Format::P1dB);
}
if(pref.Marker.defaultBehavior.showNonUniformity) {
ret.push_back(Format::NonUniformity);
if(pref.Marker.defaultBehavior.showFlatness) {
ret.push_back(Format::Flatness);
}
if(pref.Marker.defaultBehavior.showMaxDeltaNeg) {
ret.push_back(Format::maxDeltaNeg);
@ -567,8 +567,8 @@ QString Marker::readableData(Format f)
return "Input P1dB:"+Unit::ToString(position, "dBm", " ", 4);
}
break;
case Format::NonUniformity:
return "Non-uniformity:"+Unit::ToString(maxDeltaNeg+maxDeltaPos, "dB", " ", 4);
case Format::Flatness:
return "Flatness:"+Unit::ToString(maxDeltaNeg+maxDeltaPos, "dB", " ", 4);
break;
case Format::maxDeltaNeg:
return "max. Δ-:"+Unit::ToString(maxDeltaNeg, "dB", " ", 4);
@ -652,7 +652,7 @@ QString Marker::readableSettings()
return "none";
case Type::PhaseNoise:
return Unit::ToString(offset, "Hz", " kM", 4);
case Type::NonUniformity:
case Type::Flatness:
return "None";
default:
break;
@ -1016,7 +1016,7 @@ std::set<Marker::Type> Marker::getSupportedTypes()
supported.insert(Type::Minimum);
supported.insert(Type::Delta);
supported.insert(Type::PeakTable);
supported.insert(Type::NonUniformity);
supported.insert(Type::Flatness);
if(!parentTrace->isReflection()) {
supported.insert(Type::Lowpass);
supported.insert(Type::Highpass);
@ -1202,7 +1202,7 @@ void Marker::setType(Marker::Type t)
case Type::PhaseNoise:
required_helpers = {{"o", "Offset", Type::Manual}};
break;
case Type::NonUniformity:
case Type::Flatness:
required_helpers = {{"l", "Lower Limit", Type::Manual}, {"u", "Upper Limit", Type::Manual}};
break;
default:
@ -1216,7 +1216,7 @@ void Marker::setType(Marker::Type t)
helper->setType(h.type);
helperMarkers.push_back(helper);
}
if(type == Type::NonUniformity) {
if(type == Type::Flatness) {
// need to update when any of the helper markers is moved
for(auto h : helperMarkers) {
connect(h, &Marker::positionChanged, [=](){
@ -1764,6 +1764,7 @@ void Marker::update()
// empty trace, nothing to do
return;
}
lines.clear();
auto xmin = restrictPosition ? minPosition : numeric_limits<double>::lowest();
auto xmax = restrictPosition ? maxPosition : numeric_limits<double>::max();
switch(type) {
@ -1922,28 +1923,47 @@ void Marker::update()
setPosition(p1db);
}
break;
case Type::NonUniformity: {
auto dbLower = Util::SparamTodB(helperMarkers[0]->getData());
auto dbUpper = Util::SparamTodB(helperMarkers[1]->getData());
case Type::Flatness: {
auto lower = helperMarkers[0]->getData();
auto upper = helperMarkers[1]->getData();
auto posLower = helperMarkers[0]->getPosition();
auto posUpper = helperMarkers[1]->getPosition();
// three additional lines:
// 0: line between lower and upper markers
// 1: positive peak deviation
// 2: negative peak deviation
lines.resize(3);
lines[0].p1.x = posLower;
lines[0].p1.y = lower;
lines[0].p2.x = posUpper;
lines[0].p2.y = upper;
if(posLower > posUpper) {
swap(posLower, posUpper);
swap(dbLower, dbUpper);
swap(lower, upper);
}
auto startIndex = parentTrace->index(posLower);
auto stopIndex = parentTrace->index(posUpper);
maxDeltaNeg = std::numeric_limits<double>::lowest();
maxDeltaPos = std::numeric_limits<double>::lowest();
for(int i=startIndex;i<=stopIndex;i++) {
auto dbTrace = Util::SparamTodB(parentTrace->sample(i).y);
auto dbStraightLine = Util::Scale((double) i, (double) startIndex, (double) stopIndex, dbLower, dbUpper);
auto sample = parentTrace->sample(i);
auto dbTrace = Util::SparamTodB(sample.y);
auto dbStraightLine = Util::Scale((double) i, (double) startIndex, (double) stopIndex, Util::SparamTodB(lower), Util::SparamTodB(upper));
auto straightLine = Util::dBToMagnitude(dbStraightLine);
auto delta = dbTrace - dbStraightLine;
if(delta > maxDeltaPos) {
maxDeltaPos = delta;
lines[1].p1.x = sample.x;
lines[1].p1.y = sample.y;
lines[1].p2.x = sample.x;
lines[1].p2.y = straightLine;
}
if(-delta > maxDeltaNeg) {
maxDeltaNeg = -delta;
lines[2].p1.x = sample.x;
lines[2].p1.y = sample.y;
lines[2].p2.x = sample.x;
lines[2].p2.y = straightLine;
}
}
}
@ -1972,8 +1992,8 @@ std::complex<double> Marker::getData() const
bool Marker::isMovable()
{
if(parent) {
if(parent->type == Type::NonUniformity) {
// non-uniformity is the exception, it has movable helper markers
if(parent->type == Type::Flatness) {
// flatness is the exception, it has movable helper markers
return true;
}
// helper traces are never movable by the user
@ -1994,8 +2014,8 @@ bool Marker::isMovable()
bool Marker::isEditable()
{
if(parent) {
if(parent->type == Type::NonUniformity) {
// non-uniformity is the exception, it has movable helper markers
if(parent->type == Type::Flatness) {
// flatness is the exception, it has movable helper markers
return true;
}
// helper traces are never movable by the user
@ -2027,3 +2047,8 @@ Trace::DataType Marker::getDomain()
return Trace::DataType::Invalid;
}
std::vector<Marker::Line> Marker::getLines()
{
return lines;
}

View File

@ -47,7 +47,7 @@ public:
AvgModulationProduct, // average level of modulation products
// compression parameters
P1dB, // power level at 1dB compression
NonUniformity,
Flatness,
maxDeltaPos,
maxDeltaNeg,
// keep last at end
@ -74,6 +74,12 @@ public:
bool isEditable();
Trace::DataType getDomain();
class Line {
public:
TraceMath::Data p1, p2;
};
std::vector<Line> getLines();
QPixmap& getSymbol();
unsigned long getCreationTimestamp() const;
@ -96,7 +102,7 @@ public:
TOI,
PhaseNoise,
P1dB,
NonUniformity,
Flatness,
// keep last at end
Last,
};
@ -176,7 +182,7 @@ private:
case Type::TOI: return "TOI/IP3";
case Type::PhaseNoise: return "Phase noise";
case Type::P1dB: return "1dB compression";
case Type::NonUniformity: return "Non-uniformity";
case Type::Flatness: return "Flatness";
default: return QString();
}
}
@ -212,6 +218,10 @@ private:
Marker *delta;
std::vector<Marker*> helperMarkers;
Marker *parent;
// additional lines the marker wants to show on the graphs (the graphs are responsible for drawing the lines)
std::vector<Line> lines;
// settings for the different marker types
double cutoffAmplitude;
double peakThreshold;

View File

@ -448,7 +448,7 @@ Marker *TracePlot::markerAtPosition(QPoint p, bool onlyMovable)
closestDistance = distance;
if(m->getParent()) {
closestMarker = m->getParent();
if(closestMarker->getType() == Marker::Type::NonUniformity) {
if(closestMarker->getType() == Marker::Type::Flatness) {
closestMarker = m;
}
} else {

View File

@ -607,6 +607,24 @@ void TraceXYPlot::draw(QPainter &p)
markerPoint = traceToCoordinate(t, t->index(xPosition), yAxis[i]);
}
auto point = plotValueToPixel(markerPoint, i);
for(auto line : m->getLines()) {
QPointF pF1 = QPointF(numeric_limits<double>::quiet_NaN(), numeric_limits<double>::quiet_NaN());
pF1.setX(xAxis.sampleToCoordinate(line.p1));
pF1.setY(yAxis[0].sampleToCoordinate(line.p1));
QPointF pF2 = QPointF(numeric_limits<double>::quiet_NaN(), numeric_limits<double>::quiet_NaN());
pF2.setX(xAxis.sampleToCoordinate(line.p2));
pF2.setY(yAxis[0].sampleToCoordinate(line.p2));
auto p1 = plotValueToPixel(pF1, i);
auto p2 = plotValueToPixel(pF2, i);
if(!plotRect.contains(p1) && !plotRect.contains(p2)) {
// completely out of frame
continue;
}
// draw line
p.drawLine(p1, p2);
}
if(!plotRect.contains(point)) {
// out of screen
continue;

View File

@ -11,7 +11,7 @@
namespace Util {
template<typename T> T Scale(T value, T from_low, T from_high, T to_low, T to_high, bool log_from = false, bool log_to = false) {
double normalized;
T normalized;
if(log_from) {
normalized = log10(value / from_low) / log10(from_high / from_low);
} else {

View File

@ -380,7 +380,7 @@ void PreferencesDialog::setInitialGUIState()
ui->MarkerShowAvgTone->setChecked(p->Marker.defaultBehavior.showAvgTone);
ui->MarkerShowAvgMod->setChecked(p->Marker.defaultBehavior.showAvgModulation);
ui->MarkerShowP1dB->setChecked(p->Marker.defaultBehavior.showP1dB);
ui->MarkerShowNonUniformity->setChecked(p->Marker.defaultBehavior.showNonUniformity);
ui->MarkerShowFlatness->setChecked(p->Marker.defaultBehavior.showFlatness);
ui->MarkerShowMaxDeltaNeg->setChecked(p->Marker.defaultBehavior.showMaxDeltaNeg);
ui->MarkerShowMaxDeltaPos->setChecked(p->Marker.defaultBehavior.showMaxDeltaPos);
ui->MarkerInterpolate->setCurrentIndex(p->Marker.interpolatePoints ? 1 : 0);
@ -488,7 +488,7 @@ void PreferencesDialog::updateFromGUI()
p->Marker.defaultBehavior.showAvgTone = ui->MarkerShowAvgTone->isChecked();
p->Marker.defaultBehavior.showAvgModulation = ui->MarkerShowAvgMod->isChecked();
p->Marker.defaultBehavior.showP1dB = ui->MarkerShowP1dB->isChecked();
p->Marker.defaultBehavior.showNonUniformity = ui->MarkerShowNonUniformity->isChecked();
p->Marker.defaultBehavior.showFlatness = ui->MarkerShowFlatness->isChecked();
p->Marker.defaultBehavior.showMaxDeltaNeg = ui->MarkerShowMaxDeltaNeg->isChecked();
p->Marker.defaultBehavior.showMaxDeltaPos = ui->MarkerShowMaxDeltaPos->isChecked();
p->Marker.interpolatePoints = ui->MarkerInterpolate->currentIndex() == 1;

View File

@ -150,7 +150,7 @@ public:
struct {
bool showDataOnGraphs;
bool showdB, showdBm, showdBuV, showdBAngle, showRealImag, showImpedance, showVSWR, showResistance, showCapacitance, showInductance, showQualityFactor;
bool showNoise, showPhasenoise, showCenterBandwidth, showCutoff, showInsertionLoss, showTOI, showAvgTone, showAvgModulation, showP1dB, showNonUniformity, showMaxDeltaNeg, showMaxDeltaPos;
bool showNoise, showPhasenoise, showCenterBandwidth, showCutoff, showInsertionLoss, showTOI, showAvgTone, showAvgModulation, showP1dB, showFlatness, showMaxDeltaNeg, showMaxDeltaPos;
} defaultBehavior;
bool interpolatePoints;
MarkerSortOrder sortOrder;
@ -264,7 +264,7 @@ private:
{&Marker.defaultBehavior.showAvgTone, "Marker.defaultBehavior.showAvgTone", true},
{&Marker.defaultBehavior.showAvgModulation, "Marker.defaultBehavior.showAvgModulation", true},
{&Marker.defaultBehavior.showP1dB, "Marker.defaultBehavior.showP1dB", true},
{&Marker.defaultBehavior.showNonUniformity, "Marker.defaultBehavior.showNonUniformity", true},
{&Marker.defaultBehavior.showFlatness, "Marker.defaultBehavior.showNonUniformity", true},
{&Marker.defaultBehavior.showMaxDeltaNeg, "Marker.defaultBehavior.showMaxDeltaNeg", true},
{&Marker.defaultBehavior.showMaxDeltaPos, "Marker.defaultBehavior.showMaxDeltaPos", true},
{&Marker.interpolatePoints, "Marker.interpolatePoints", false},

View File

@ -107,8 +107,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>749</width>
<height>920</height>
<width>530</width>
<height>937</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@ -712,8 +712,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>749</width>
<height>846</height>
<width>565</width>
<height>863</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_21">
@ -1033,8 +1033,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>749</width>
<height>952</height>
<width>553</width>
<height>969</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_22">
@ -1641,9 +1641,9 @@
</widget>
</item>
<item>
<widget class="QCheckBox" name="MarkerShowNonUniformity">
<widget class="QCheckBox" name="MarkerShowFlatness">
<property name="text">
<string>Non-uniformity</string>
<string>Flatness</string>
</property>
</widget>
</item>
@ -1885,8 +1885,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>763</width>
<height>561</height>
<width>126</width>
<height>90</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_24">
@ -1956,8 +1956,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>763</width>
<height>561</height>
<width>263</width>
<height>241</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_19">