mirror of
https://github.com/jankae/LibreVNA.git
synced 2026-04-06 15:04:11 +00:00
Add setting for graph behavior when trace no longer supported
This commit is contained in:
parent
b45645f04e
commit
dda149f3d5
11 changed files with 363 additions and 227 deletions
|
|
@ -15,6 +15,7 @@ TracePlot::TracePlot(TraceModel &model, QWidget *parent)
|
|||
: QWidget(parent),
|
||||
model(model),
|
||||
selectedMarker(nullptr),
|
||||
traceRemovalPending(false),
|
||||
dropPending(false),
|
||||
dropTrace(nullptr)
|
||||
{
|
||||
|
|
@ -96,6 +97,17 @@ void TracePlot::initializeTraceInfo()
|
|||
connect(&model, &TraceModel::traceAdded, this, &TracePlot::newTraceAvailable);
|
||||
}
|
||||
|
||||
std::vector<Trace *> TracePlot::activeTraces()
|
||||
{
|
||||
std::vector<Trace*> ret;
|
||||
for(auto t : traces) {
|
||||
if(t.second) {
|
||||
ret.push_back(t.first);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void TracePlot::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
auto m = markerAtPosition(event->pos());
|
||||
|
|
@ -117,13 +129,25 @@ void TracePlot::contextMenuEvent(QContextMenuEvent *event)
|
|||
|
||||
void TracePlot::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
if(traceRemovalPending) {
|
||||
for(auto t : traces) {
|
||||
if(!t.second) {
|
||||
// trace already disabled
|
||||
}
|
||||
if(!supported(t.first)) {
|
||||
enableTrace(t.first, false);
|
||||
}
|
||||
}
|
||||
traceRemovalPending = false;
|
||||
}
|
||||
|
||||
Q_UNUSED(event)
|
||||
auto pref = Preferences::getInstance();
|
||||
QPainter p(this);
|
||||
// p.setRenderHint(QPainter::Antialiasing);
|
||||
// fill background
|
||||
p.setBackground(QBrush(pref.General.graphColors.background));
|
||||
p.fillRect(0, 0, width(), height(), QBrush(pref.General.graphColors.background));
|
||||
p.setBackground(QBrush(pref.Graphs.Color.background));
|
||||
p.fillRect(0, 0, width(), height(), QBrush(pref.Graphs.Color.background));
|
||||
|
||||
// show names of active traces and marker data (if enabled)
|
||||
bool hasMarkerData = false;
|
||||
|
|
@ -374,7 +398,27 @@ void TracePlot::checkIfStillSupported(Trace *t)
|
|||
{
|
||||
if(!supported(t)) {
|
||||
// something with this trace changed and it can no longer be displayed on this graph
|
||||
enableTrace(t, false);
|
||||
// behavior depends on preferences
|
||||
switch(Preferences::getInstance().Graphs.domainChangeBehavior) {
|
||||
case GraphDomainChangeBehavior::RemoveChangedTraces:
|
||||
// simply remove the changed trace
|
||||
enableTrace(t, false);
|
||||
break;
|
||||
case GraphDomainChangeBehavior::AdjustGrahpsIfOnlyTrace:
|
||||
// remove trace if other traces are present, otherwise try to adjust graph
|
||||
if(activeTraces().size() > 1) {
|
||||
enableTrace(t, false);
|
||||
break;
|
||||
}
|
||||
[[fallthrough]];
|
||||
case GraphDomainChangeBehavior::AdjustGraphs:
|
||||
// attempt to configure the graph for the changed trace, remove only if this fails
|
||||
if(!configureForTrace(t)) {
|
||||
enableTrace(t, false);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue