From 581d2497c869703470f538869f2334286221fd85 Mon Sep 17 00:00:00 2001 From: edouard Date: Sun, 13 Mar 2011 14:14:52 +0000 Subject: [PATCH] OP-247 Scope gadget: restore checked/unchecked state of curve legends when unhiding. git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@3032 ebee16cc-31ac-478f-84a7-5cbb03baadba --- .../src/plugins/scope/scopegadgetwidget.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp index df5c8b4fc..3b11768bf 100644 --- a/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp +++ b/ground/openpilotgcs/src/plugins/scope/scopegadgetwidget.cpp @@ -207,6 +207,16 @@ void ScopeGadgetWidget::addLegend() // legend->setFrameStyle(QFrame::Box | QFrame::Sunken); // insertLegend(legend, QwtPlot::BottomLegend); + // Update the checked/unchecked state of the legend items + // -> this is necessary when hiding a legend where some plots are + // not visible, and the un-hiding it. + foreach (QwtPlotItem *item, this->itemList()) { + bool on = item->isVisible(); + QWidget *w = legend->find(item); + if ( w && w->inherits("QwtLegendItem") ) + ((QwtLegendItem *)w)->setChecked(!on); + } + connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)), this, SLOT(showCurve(QwtPlotItem *, bool))); }