mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-01-06 08:40:05 +01:00
Improve automatic graph configuraion when traces change domains
This commit is contained in:
parent
7dd2c0501e
commit
d99dab35aa
|
|
@ -317,6 +317,11 @@ YAxis::Type YAxis::getType() const
|
|||
return type;
|
||||
}
|
||||
|
||||
bool YAxis::isSupported(XAxis::Type type, TraceModel::DataSource source)
|
||||
{
|
||||
return getSupported(type, source).count(this->type);
|
||||
}
|
||||
|
||||
std::set<YAxis::Type> YAxis::getSupported(XAxis::Type type, TraceModel::DataSource source)
|
||||
{
|
||||
std::set<YAxis::Type> ret = {YAxis::Type::Disabled};
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ public:
|
|||
|
||||
Type getType() const;
|
||||
|
||||
bool isSupported(XAxis::Type type, TraceModel::DataSource source);
|
||||
static std::set<YAxis::Type> getSupported(XAxis::Type type, TraceModel::DataSource source);
|
||||
static std::complex<double> reconstructValueFromYAxisType(std::map<Type, double> yaxistypes);
|
||||
|
||||
|
|
|
|||
|
|
@ -788,12 +788,18 @@ void TracePlot::checkIfStillSupported(Trace *t)
|
|||
// attempt to configure the graph for the changed trace, remove only if this fails
|
||||
if(!configureForTrace(t)) {
|
||||
enableTrace(t, false);
|
||||
}
|
||||
// remove non-supported traces after graph has been adjusted
|
||||
for(auto t : activeTraces()) {
|
||||
if(!supported(t)) {
|
||||
enableTrace(t, false);
|
||||
}
|
||||
} else {
|
||||
// other trace may need to be removed because the graph no longer supports them. However, they (the traces)
|
||||
// may change soon as well (e.g. because multiple traces changed at the same time and we are only handling
|
||||
// the first changed trace right now). Postpone the deletion of other traces until all currently executing
|
||||
// slots have completed
|
||||
QTimer::singleShot(0, [this]{
|
||||
for(auto t : activeTraces()) {
|
||||
if(!supported(t)) {
|
||||
enableTrace(t, false);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,14 +159,16 @@ void TraceWaterfall::resetWaterfall()
|
|||
|
||||
bool TraceWaterfall::configureForTrace(Trace *t)
|
||||
{
|
||||
YAxis::Type yDefault = YAxis::Type::Disabled;
|
||||
|
||||
switch(t->outputType()) {
|
||||
case Trace::DataType::Frequency:
|
||||
xAxis.set(XAxis::Type::Frequency, false, true, 0, 1, 0.1);
|
||||
yAxis.set(YAxis::Type::Magnitude, false, true, 0, 1, 1.0);
|
||||
yDefault = YAxis::Type::Magnitude;
|
||||
break;
|
||||
case Trace::DataType::Power:
|
||||
xAxis.set(XAxis::Type::Power, false, true, 0, 1, 0.1);
|
||||
yAxis.set(YAxis::Type::Magnitude, false, true, 0, 1, 1.0);
|
||||
yDefault = YAxis::Type::Magnitude;
|
||||
break;
|
||||
case Trace::DataType::Time:
|
||||
case Trace::DataType::TimeZeroSpan:
|
||||
|
|
@ -174,6 +176,9 @@ bool TraceWaterfall::configureForTrace(Trace *t)
|
|||
// unable to add
|
||||
return false;
|
||||
}
|
||||
if(!yAxis.isSupported(xAxis.getType(), getModel().getSource())) {
|
||||
yAxis.set(yDefault, false, true, 0, 1, 1.0);
|
||||
}
|
||||
traceRemovalPending = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -287,31 +287,39 @@ void TraceXYPlot::axisSetupDialog()
|
|||
|
||||
bool TraceXYPlot::configureForTrace(Trace *t)
|
||||
{
|
||||
YAxis::Type yLeftDefault = YAxis::Type::Disabled;
|
||||
YAxis::Type yRightDefault = YAxis::Type::Disabled;
|
||||
|
||||
switch(t->outputType()) {
|
||||
case Trace::DataType::Frequency:
|
||||
setXAxis(XAxis::Type::Frequency, XAxisMode::FitTraces, false, 0, 1, 0.1);
|
||||
setYAxis(0, YAxis::Type::Magnitude, false, true, 0, 1, 1.0);
|
||||
setYAxis(1, YAxis::Type::Phase, false, true, 0, 1, 1.0);
|
||||
yLeftDefault = YAxis::Type::Magnitude;
|
||||
yRightDefault = YAxis::Type::Phase;
|
||||
break;
|
||||
case Trace::DataType::Time:
|
||||
setXAxis(XAxis::Type::Time, XAxisMode::FitTraces, false, 0, 1, 0.1);
|
||||
setYAxis(0, YAxis::Type::ImpulseMag, false, true, 0, 1, 1.0);
|
||||
setYAxis(1, YAxis::Type::Disabled, false, true, 0, 1, 1.0);
|
||||
yLeftDefault = YAxis::Type::ImpulseMag;
|
||||
break;
|
||||
case Trace::DataType::Power:
|
||||
setXAxis(XAxis::Type::Power, XAxisMode::FitTraces, false, 0, 1, 0.1);
|
||||
setYAxis(0, YAxis::Type::Magnitude, false, true, 0, 1, 1.0);
|
||||
setYAxis(1, YAxis::Type::Phase, false, true, 0, 1, 1.0);
|
||||
yLeftDefault = YAxis::Type::Magnitude;
|
||||
yRightDefault = YAxis::Type::Phase;
|
||||
break;
|
||||
case Trace::DataType::TimeZeroSpan:
|
||||
setXAxis(XAxis::Type::TimeZeroSpan, XAxisMode::FitTraces, false, 0, 1, 0.1);
|
||||
setYAxis(0, YAxis::Type::Magnitude, false, true, 0, 1, 1.0);
|
||||
setYAxis(1, YAxis::Type::Phase, false, true, 0, 1, 1.0);
|
||||
yLeftDefault = YAxis::Type::Magnitude;
|
||||
yRightDefault = YAxis::Type::Phase;
|
||||
break;
|
||||
case Trace::DataType::Invalid:
|
||||
// unable to add
|
||||
return false;
|
||||
}
|
||||
if(!yAxis[0].isSupported(xAxis.getType(), getModel().getSource())) {
|
||||
setYAxis(0, yLeftDefault, false, true, 0, 1, 1.0);
|
||||
}
|
||||
if(!yAxis[1].isSupported(xAxis.getType(), getModel().getSource())) {
|
||||
setYAxis(1, yRightDefault, false, true, 0, 1, 1.0);
|
||||
}
|
||||
traceRemovalPending = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue