Skip to content

Commit

Permalink
adc: Add DockWidget to adc and fft plots
Browse files Browse the repository at this point in the history
Signed-off-by: Andrei-Fabian-Pop <[email protected]>
  • Loading branch information
Andrei-Fabian-Pop committed Dec 3, 2024
1 parent 4203959 commit 3eca44b
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions gui/src/docking/dockableareakdab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void DockableArea::addDockWrapper(DockWrapperInterface *dockWrapper)
{
KDDockWidgets::QtWidgets::DockWidget *dockWrapperWidget =
dynamic_cast<KDDockWidgets::QtWidgets::DockWidget *>(dockWrapper);
dockWrapperWidget->setAffinities({uniqueName()});
if(dockWrapperWidget) {
addDockWidget(dockWrapperWidget, KDDockWidgets::Location_OnRight);
} else {
Expand Down
8 changes: 6 additions & 2 deletions plugins/adc/src/freq/fftplotcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ using namespace adc;
FFTPlotComponent::FFTPlotComponent(QString name, uint32_t uuid, QWidget *parent)
: PlotComponent(name, uuid, parent)
{
m_fftPlot = new PlotWidget(this);
m_dockableArea = new DockableArea(this);
m_plotLayout->addWidget(m_dockableArea);

m_fftDockWrapper = new DockWrapper("FFT Plot");
m_fftPlot = new PlotWidget(this);
m_fftPlot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_fftPlot->xAxis()->setInterval(0, 1);
m_fftPlot->xAxis()->setVisible(true);
m_fftPlot->yAxis()->setUnits("dB");
m_fftDockWrapper->setInnerWidget(m_fftPlot);

m_plots.append(m_fftPlot);
m_plotLayout->addWidget(m_fftPlot);

auto nameLbl = m_fftPlot->getPlotInfo()->addLabelInfo(IP_LEFT, IP_TOP);
nameLbl->setText(m_name);
Expand All @@ -58,6 +61,7 @@ FFTPlotComponent::FFTPlotComponent(QString name, uint32_t uuid, QWidget *parent)

m_plotMenu = new FFTPlotComponentSettings(this, parent);
addComponent(m_plotMenu);
m_dockableArea->setAllDockWrappers({m_fftDockWrapper});

connect(m_plotMenu, &FFTPlotComponentSettings::requestDeletePlot, this, [=]() { Q_EMIT requestDeletePlot(); });
m_cursor = new CursorController(m_fftPlot, this);
Expand Down
6 changes: 5 additions & 1 deletion plugins/adc/src/freq/fftplotcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@
#include <plotautoscaler.h>

#include <plotwidget.h>
#include "plotinfo.h"
#include "plotcomponent.h"
#include "fftplotcomponentsettings.h"
#include <widgets/plotinfowidgets.h>
#include <gui/docking/dockablearea.h>
#include <gui/docking/dockwrapper.h>

namespace scopy {
namespace adc {
Expand All @@ -65,6 +66,9 @@ class SCOPY_ADC_EXPORT FFTPlotComponent : public PlotComponent
PlotWidget *m_fftPlot;
FFTSamplingInfo *m_fftInfo;

DockableArea *m_dockableArea;
DockWrapper *m_fftDockWrapper;

FFTPlotComponentSettings *m_plotMenu;
};
} // namespace adc
Expand Down
16 changes: 13 additions & 3 deletions plugins/adc/src/time/timeplotcomponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,22 @@ TimePlotComponent::TimePlotComponent(QString name, uint32_t uuid, QWidget *paren
, m_XYXChannel(nullptr)
, m_singleYMode(true)
{
m_dockableArea = new DockableArea(this);
m_plotLayout->addWidget(m_dockableArea);

m_timeDockWidget = new DockWrapper("Time Plot");
m_timePlot = new PlotWidget(this);
m_timePlot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_timePlot->xAxis()->setInterval(0, 1);
m_timePlot->xAxis()->setVisible(true);
m_timeDockWidget->setInnerWidget(m_timePlot);

m_xyDockWidget = new DockWrapper("XY Plot");
m_xyPlot = new PlotWidget(this);
m_xyPlot->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
m_xyPlot->xAxis()->setInterval(-2048, 2048);
m_xyPlot->xAxis()->setVisible(true);
m_xyDockWidget->setInnerWidget(m_xyPlot);

m_plots.append(m_timePlot);
m_plots.append(m_xyPlot);
Expand All @@ -70,15 +77,14 @@ TimePlotComponent::TimePlotComponent(QString name, uint32_t uuid, QWidget *paren
[=]() { m_info->update(m_currentSamplingInfo); });
*/

m_plotLayout->addWidget(m_timePlot);
m_plotLayout->addWidget(m_xyPlot);

// Need to set this for some reason .. spinboxes should be refactored
m_timePlot->yAxis()->setUnits("V");

m_plotMenu = new TimePlotComponentSettings(this, parent);
addComponent(m_plotMenu);

m_dockableArea->setAllDockWrappers({m_timeDockWidget, m_xyDockWidget});

connect(m_plotMenu, &TimePlotComponentSettings::requestDeletePlot, this, [=]() { Q_EMIT requestDeletePlot(); });
m_cursor = new CursorController(m_timePlot, this);
}
Expand Down Expand Up @@ -220,3 +226,7 @@ bool TimePlotComponent::singleYMode() const { return m_singleYMode; }
TimePlotComponentSettings *TimePlotComponent::createPlotMenu(QWidget *parent) { return m_plotMenu; }

TimePlotComponentSettings *TimePlotComponent::plotMenu() { return m_plotMenu; }

DockWrapper *TimePlotComponent::timeDockWidget() const { return m_timeDockWidget; }

DockWrapper *TimePlotComponent::xyDockWidget() const { return m_xyDockWidget; }
9 changes: 9 additions & 0 deletions plugins/adc/src/time/timeplotcomponent.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
#include "plotinfo.h"
#include <gui/plotcomponent.h>
#include <gui/widgets/plotinfowidgets.h>
#include <gui/docking/dockwrapper.h>
#include <gui/docking/dockablearea.h>

namespace scopy {
namespace adc {
Expand Down Expand Up @@ -74,6 +76,9 @@ public Q_SLOTS:
TimePlotComponentSettings *createPlotMenu(QWidget *parent);
TimePlotComponentSettings *plotMenu();

DockWrapper *timeDockWidget() const;
DockWrapper *xyDockWidget() const;

bool singleYMode() const;

TimeSamplingInfo *timePlotInfo() const;
Expand All @@ -96,6 +101,10 @@ private Q_SLOTS:
TimeSamplingInfo *m_timePlotInfo;
const float *xyXData;

DockableArea *m_dockableArea;
DockWrapper *m_timeDockWidget;
DockWrapper *m_xyDockWidget;

private:
QMetaObject::Connection xyDataConn;
QMetaObject::Connection xyAxisMinConn;
Expand Down
2 changes: 1 addition & 1 deletion plugins/adc/src/time/timeplotcomponentsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ TimePlotComponentSettings::TimePlotComponentSettings(TimePlotComponent *plt, QWi
m_xAxisShow = new MenuOnOffSwitch("XY - Plot X source", plotMenu, false);

connect(xySwitch, &QAbstractButton::toggled, this, [=](bool b) {
m_plotComponent->xyPlot()->setVisible(b);
m_plotComponent->xyDockWidget()->setActivated(b);
m_xAxisSrc->setVisible(b);
m_xAxisShow->setVisible(b);
});
Expand Down

0 comments on commit 3eca44b

Please sign in to comment.