From d8f2da900527443bcf7a92ecd3464333a84aaede Mon Sep 17 00:00:00 2001 From: "andrei.danila" Date: Wed, 17 Apr 2024 13:01:36 +0300 Subject: [PATCH] plugins/swiotrefactor/ad: Added info btn(contains acquisition details). Signed-off-by: andrei.danila --- .../include/swiotrefactor/ad74413r/ad74413r.h | 3 ++- .../swiotrefactor/src/ad74413r/ad74413r.cpp | 25 +++++++++++++++++-- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/plugins/swiotrefactor/include/swiotrefactor/ad74413r/ad74413r.h b/plugins/swiotrefactor/include/swiotrefactor/ad74413r/ad74413r.h index 579e97d45b..d0244356fb 100644 --- a/plugins/swiotrefactor/include/swiotrefactor/ad74413r/ad74413r.h +++ b/plugins/swiotrefactor/include/swiotrefactor/ad74413r/ad74413r.h @@ -88,6 +88,7 @@ private Q_SLOTS: void onChannelBtnChecked(int chnWidgetId, bool en); private: + bool eventFilter(QObject *watched, QEvent *event) override; void updateXData(int dataSize); void plotData(QVector curveData, int chnlIdx); void createDevicesMap(iio_context *ctx); @@ -124,9 +125,9 @@ private Q_SLOTS: ToolTemplate *m_tool; RunBtn *m_runBtn; SingleShotBtn *m_singleBtn; - PrintBtn *m_printBtn; QPushButton *m_configBtn; GearBtn *m_settingsBtn; + InfoBtn *m_infoBtn; PlotWidget *m_plot; TimePlotInfo *m_info; diff --git a/plugins/swiotrefactor/src/ad74413r/ad74413r.cpp b/plugins/swiotrefactor/src/ad74413r/ad74413r.cpp index 7d7fcde8ec..83f2e808e2 100644 --- a/plugins/swiotrefactor/src/ad74413r/ad74413r.cpp +++ b/plugins/swiotrefactor/src/ad74413r/ad74413r.cpp @@ -504,6 +504,8 @@ void Ad74413r::setupToolTemplate() setupDeviceBtn(); m_tool->addWidgetToCentralContainerHelper(m_plot); + m_infoBtn = new InfoBtn(this); + m_infoBtn->installEventFilter(this); m_settingsBtn = new GearBtn(this); m_runBtn = new RunBtn(this); m_runBtn->setEnabled(false); @@ -511,7 +513,6 @@ void Ad74413r::setupToolTemplate() m_singleBtn = new SingleShotBtn(this); m_singleBtn->setEnabled(false); m_singleBtn->setChecked(false); - m_printBtn = new PrintBtn(this); m_configBtn = createConfigBtn(); MenuControlButton *chnlsMenuBtn = new MenuControlButton(this); @@ -546,7 +547,8 @@ void Ad74413r::setupToolTemplate() m_tool->addWidgetToTopContainerHelper(m_runBtn, TTA_RIGHT); m_tool->addWidgetToTopContainerHelper(m_singleBtn, TTA_RIGHT); - m_tool->addWidgetToTopContainerHelper(m_printBtn, TTA_LEFT); + + m_tool->addWidgetToTopContainerHelper(m_infoBtn, TTA_LEFT); m_tool->addWidgetToTopContainerHelper(m_configBtn, TTA_LEFT); } @@ -599,6 +601,25 @@ QWidget *Ad74413r::createSettingsMenu(QWidget *parent) return widget; } +bool Ad74413r::eventFilter(QObject *watched, QEvent *event) +{ + if(watched == (QObject *)m_infoBtn) { + if(event->type() == QEvent::Enter) { + auto enabledPlotsNo = std::count(m_enabledChannels.begin(), m_enabledChannels.end(), true); + m_infoBtn->setToolTip( + "sps = samples per second \n" + "sps = sampling_frequency / enabled_channels \n" + "Enabled channels = " + + QString::number(enabledPlotsNo) + "\n" + + "Samples per channel = " + QString::number(m_currentSamplingInfo.plotSize) + "\n" + + "Sampling frequency = " + QString::number(m_currentSamplingInfo.sampleRate)); + } + return false; + } else { + return QWidget::eventFilter(watched, event); + } +} + void Ad74413r::initTutorialProperties() { // initialize components that might be used for the AD74413R tutorial