Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gui: rename and move some widgets from gr-util #1586

Merged
merged 3 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions gr-util/include/gr-util/grtimechanneladdon.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
#include "grtimeplotaddon.h"
#include "measurementcontroller.h"
#include "scopy-gr-util_export.h"
#include "time_yautoscale.h"
#include "time_ycontrol.h"

#include "timechanneladdon.h"
#include "tooladdon.h"

Expand All @@ -19,11 +18,15 @@
#include <gui/plotchannel.h>
#include <gui/spinbox_a.hpp>
#include <gui/widgets/menucombo.h>
#include <gui/plotautoscaler.h>
#include <gui/widgets/menuplotaxisrangecontrol.h>

namespace scopy {
class MenuOnOffSwitch;

namespace grutil {

using namespace scopy::gui;

class GRDeviceAddon;
class SCOPY_GR_UTIL_EXPORT GRTimeChannelAddon : public TimeChannelAddon, public GRTopAddon
{
Expand Down Expand Up @@ -72,8 +75,8 @@ public Q_SLOTS:
GRSignalPath *m_signalPath;
GRIIOFloatChannelSrc *m_grch;
TimeMeasureManager *m_measureMgr;
TimeYControl *m_yCtrl;
TimeYAutoscale *m_autoscale;
MenuPlotAxisRangeControl *m_yCtrl;
PlotAutoscaler *m_autoscale;
MenuCombo *m_ymodeCb;
MenuOnOffSwitch *m_autoscaleBtn;
QPushButton *m_snapBtn;
Expand Down Expand Up @@ -109,8 +112,8 @@ class SCOPY_GR_UTIL_EXPORT ImportChannelAddon : public TimeChannelAddon

private:
TimeMeasureManager *m_measureMgr;
TimeYControl *m_yCtrl;
TimeYAutoscale *m_autoscale;
MenuPlotAxisRangeControl *m_yCtrl;
PlotAutoscaler *m_autoscale;

QWidget *createMenu(QWidget *parent = nullptr);
QWidget *createYAxisMenu(QWidget *parent);
Expand Down
14 changes: 9 additions & 5 deletions gr-util/include/gr-util/grtimeplotaddonsettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "grtimeplotaddon.h"
#include "scopy-gr-util_export.h"
#include "time_yautoscale.h"

#include "timechanneladdon.h"
#include "tooladdon.h"

Expand All @@ -12,10 +12,14 @@
#include <gui/spinbox_a.hpp>
#include <gui/widgets/menucombo.h>
#include <gui/widgets/menuonoffswitch.h>
#include <gui/widgets/menuplotaxisrangecontrol.h>
#include <gui/plotautoscaler.h>

namespace scopy {
namespace grutil {
class TimeYControl;

using namespace scopy::gui;

class GRTimePlotAddon;
class GRTimeChannelAddon;
class SCOPY_GR_UTIL_EXPORT GRTimePlotAddonSettings : public QObject,
Expand Down Expand Up @@ -98,11 +102,11 @@ public Q_SLOTS:
QWidget *widget;
QPen m_pen;

TimeYControl *m_yctrl;
TimeYControl *m_fftyctrl;
MenuPlotAxisRangeControl *m_yctrl;
MenuPlotAxisRangeControl *m_fftyctrl;
MenuOnOffSwitch *m_singleYModeSw;
QPushButton *m_autoscaleBtn;
TimeYAutoscale *autoscaler;
PlotAutoscaler *autoscaler;

ScaleSpinButton *m_bufferSizeSpin;
ScaleSpinButton *m_plotSizeSpin;
Expand Down
27 changes: 0 additions & 27 deletions gr-util/include/gr-util/time_ycontrol.h

This file was deleted.

12 changes: 6 additions & 6 deletions gr-util/src/grtimechanneladdon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ QWidget *GRTimeChannelAddon::createYAxisMenu(QWidget *parent)
if(m_scaleAvailable) {
cb->addItem(m_unit, YMODE_SCALE);
}

m_yCtrl = new TimeYControl(m_plotAxis, yaxis);
m_plotAxis->setUnits("V");
m_yCtrl = new MenuPlotAxisRangeControl(m_plotAxis, yaxis);

m_autoscaleBtn = new MenuOnOffSwitch(tr("AUTOSCALE"), yaxis, false);
m_autoscale = new TimeYAutoscale(this);
m_autoscale = new PlotAutoscaler(false, this);
m_autoscale->addChannels(m_plotCh);

connect(m_autoscale, &TimeYAutoscale::newMin, m_yCtrl, &TimeYControl::setMin);
connect(m_autoscale, &TimeYAutoscale::newMax, m_yCtrl, &TimeYControl::setMax);
connect(m_autoscale, &PlotAutoscaler::newMin, m_yCtrl, &MenuPlotAxisRangeControl::setMin);
connect(m_autoscale, &PlotAutoscaler::newMax, m_yCtrl, &MenuPlotAxisRangeControl::setMax);

connect(m_autoscaleBtn->onOffswitch(), &QAbstractButton::toggled, this, [=](bool b) {
m_yCtrl->setEnabled(!b);
Expand Down Expand Up @@ -426,7 +426,7 @@ QWidget *ImportChannelAddon::createYAxisMenu(QWidget *parent)
MenuSectionWidget *yaxiscontainer = new MenuSectionWidget(parent);
MenuCollapseSection *yaxis = new MenuCollapseSection("Y-AXIS", MenuCollapseSection::MHCW_NONE, yaxiscontainer);

m_yCtrl = new TimeYControl(m_plotAxis, yaxis);
m_yCtrl = new MenuPlotAxisRangeControl(m_plotAxis, yaxis);

yaxis->contentLayout()->addWidget(m_yCtrl);
yaxiscontainer->contentLayout()->addWidget(yaxis);
Expand Down
46 changes: 11 additions & 35 deletions gr-util/src/grtimeplotaddonsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
#include <gui/widgets/menulineedit.h>
#include <gui/widgets/menuonoffswitch.h>
#include <gui/widgets/menusectionwidget.h>
#include <gui/widgets/menuplotchannelcurvestylecontrol.h>

using namespace scopy::grutil;
using namespace scopy::gui;

GRTimePlotAddonSettings::GRTimePlotAddonSettings(GRTimePlotAddon *p, QObject *parent)
: QObject(parent)
Expand Down Expand Up @@ -65,13 +67,14 @@ QWidget *GRTimePlotAddonSettings::createYAxisMenu(QWidget *parent)
MenuSectionWidget *yaxiscontainer = new MenuSectionWidget(parent);
MenuCollapseSection *yaxis = new MenuCollapseSection("Y-AXIS", MenuCollapseSection::MHCW_NONE, yaxiscontainer);

m_yctrl = new TimeYControl(m_plot->plot()->yAxis(), yaxis);
m_plot->plot()->yAxis()->setUnits("V");
m_yctrl = new MenuPlotAxisRangeControl(m_plot->plot()->yAxis(), yaxis);
m_singleYModeSw = new MenuOnOffSwitch("Single Y Mode", yaxis);
m_autoscaleBtn = new QPushButton("Autoscale", yaxis);

autoscaler = new TimeYAutoscale(this);
connect(autoscaler, &TimeYAutoscale::newMin, m_yctrl, &TimeYControl::setMin);
connect(autoscaler, &TimeYAutoscale::newMax, m_yctrl, &TimeYControl::setMax);
autoscaler = new PlotAutoscaler(false, this);
connect(autoscaler, &PlotAutoscaler::newMin, m_yctrl, &MenuPlotAxisRangeControl::setMin);
connect(autoscaler, &PlotAutoscaler::newMax, m_yctrl, &MenuPlotAxisRangeControl::setMax);
StyleHelper::BlueButton(m_autoscaleBtn, "autoscale");

connect(m_autoscaleBtn, &QPushButton::clicked, this, [=]() { autoscaler->autoscale(); });
Expand Down Expand Up @@ -349,36 +352,9 @@ QWidget *GRTimePlotAddonSettings::createCurveMenu(PlotChannel *ch, QWidget *pare
{
MenuCollapseSection *curve = new MenuCollapseSection("CURVE", MenuCollapseSection::MHCW_NONE, parent);

QWidget *curveSettings = new QWidget(curve);
QHBoxLayout *curveSettingsLay = new QHBoxLayout(curveSettings);
curveSettingsLay->setMargin(0);
curveSettingsLay->setSpacing(10);
curveSettings->setLayout(curveSettingsLay);

MenuCombo *cbThicknessW = new MenuCombo("Thickness", curve);
auto cbThickness = cbThicknessW->combo();
cbThickness->addItem("1");
cbThickness->addItem("2");
cbThickness->addItem("3");
cbThickness->addItem("4");
cbThickness->addItem("5");

connect(cbThickness, qOverload<int>(&QComboBox::currentIndexChanged), this,
[=](int idx) { ch->setThickness(cbThickness->itemText(idx).toFloat()); });
MenuCombo *cbStyleW = new MenuCombo("Style", curve);
auto cbStyle = cbStyleW->combo();
cbStyle->addItem("Lines", PlotChannel::PCS_LINES);
cbStyle->addItem("Dots", PlotChannel::PCS_DOTS);
cbStyle->addItem("Steps", PlotChannel::PCS_STEPS);
cbStyle->addItem("Sticks", PlotChannel::PCS_STICKS);
cbStyle->addItem("Smooth", PlotChannel::PCS_SMOOTH);
StyleHelper::MenuComboBox(cbStyle, "cbStyle");

connect(cbStyle, qOverload<int>(&QComboBox::currentIndexChanged), this,
[=](int idx) { ch->setStyle(cbStyle->itemData(idx).toInt()); });

curveSettingsLay->addWidget(cbThicknessW);
curveSettingsLay->addWidget(cbStyleW);
MenuPlotChannelCurveStyleControl *curveSettings = new MenuPlotChannelCurveStyleControl(curve);
curveSettings->addChannels(ch);

curve->contentLayout()->addWidget(curveSettings);
return curve;
}
Expand Down Expand Up @@ -482,7 +458,7 @@ QWidget *GRTimePlotAddonSettings::createFFTMenu(QWidget *parent)
fftLayout->addWidget(m_fftwindow);
fftLayout->addWidget(m_freqOffsetSpin);

m_fftyctrl = new TimeYControl(m_plot->fftplotch()->yAxis(), fft);
m_fftyctrl = new MenuPlotAxisRangeControl(m_plot->fftplotch()->yAxis(), fft);
fftLayout->addWidget(m_fftyctrl);

auto curve = createCurveMenu(m_plot->fftplotch(), fft);
Expand Down
52 changes: 0 additions & 52 deletions gr-util/src/time_ycontrol.cpp

This file was deleted.

35 changes: 5 additions & 30 deletions gr-util/src/timechanneladdon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
#include <menucollapsesection.h>
#include <menucombo.h>
#include <menusectionwidget.h>
#include <gui/widgets/menuplotchannelcurvestylecontrol.h>

Q_LOGGING_CATEGORY(CAT_TIME_CHANNEL, "TimeChannelAddon");

using namespace scopy;
using namespace scopy::gui;
using namespace scopy::grutil;

ChannelAddon::ChannelAddon(QString ch, PlotAddon *plotAddon, QPen pen, QObject *parent)
Expand Down Expand Up @@ -77,36 +79,9 @@ QWidget *ChannelAddon::createCurveMenu(QWidget *parent)
MenuSectionWidget *curvecontainer = new MenuSectionWidget(parent);
MenuCollapseSection *curve = new MenuCollapseSection("CURVE", MenuCollapseSection::MHCW_NONE, curvecontainer);

QWidget *curveSettings = new QWidget(curve);
QHBoxLayout *curveSettingsLay = new QHBoxLayout(curveSettings);
curveSettingsLay->setMargin(0);
curveSettingsLay->setSpacing(10);
curveSettings->setLayout(curveSettingsLay);

MenuCombo *cbThicknessW = new MenuCombo("Thickness", curve);
auto cbThickness = cbThicknessW->combo();
cbThickness->addItem("1");
cbThickness->addItem("2");
cbThickness->addItem("3");
cbThickness->addItem("4");
cbThickness->addItem("5");

connect(cbThickness, qOverload<int>(&QComboBox::currentIndexChanged), this,
[=](int idx) { m_plotCh->setThickness(cbThickness->itemText(idx).toFloat()); });
MenuCombo *cbStyleW = new MenuCombo("Style", curve);
auto cbStyle = cbStyleW->combo();
cbStyle->addItem("Lines", PlotChannel::PCS_LINES);
cbStyle->addItem("Dots", PlotChannel::PCS_DOTS);
cbStyle->addItem("Steps", PlotChannel::PCS_STEPS);
cbStyle->addItem("Sticks", PlotChannel::PCS_STICKS);
cbStyle->addItem("Smooth", PlotChannel::PCS_SMOOTH);
StyleHelper::MenuComboBox(cbStyle, "cbStyle");

connect(cbStyle, qOverload<int>(&QComboBox::currentIndexChanged), this,
[=](int idx) { m_plotCh->setStyle(cbStyle->itemData(idx).toInt()); });

curveSettingsLay->addWidget(cbThicknessW);
curveSettingsLay->addWidget(cbStyleW);
MenuPlotChannelCurveStyleControl *curveSettings = new MenuPlotChannelCurveStyleControl(curve);
curveSettings->addChannels(m_plotCh);

curve->contentLayout()->addWidget(curveSettings);
curvecontainer->contentLayout()->addWidget(curve);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
#ifndef TIMEYAUTOSCALE_H
#define TIMEYAUTOSCALE_H
#ifndef PLOTAUTOSCALER_H
#define PLOTAUTOSCALER_H

#include "scopy-gr-util_export.h"
#include "scopy-gui_export.h"

#include <QObject>
#include <QWidget>

#include <plotchannel.h>
#include <spinbox_a.hpp>

namespace scopy::grutil {
namespace scopy::gui {

class SCOPY_GR_UTIL_EXPORT TimeYAutoscale : public QObject
class SCOPY_GUI_EXPORT PlotAutoscaler : public QObject
{
Q_OBJECT
public:
TimeYAutoscale(QObject *parent);
~TimeYAutoscale();
PlotAutoscaler(bool xAxis = false, QObject *parent = nullptr);
~PlotAutoscaler();
Q_SIGNALS:
void newMin(double);
void newMax(double);
Expand All @@ -31,6 +31,7 @@ public Q_SLOTS:
private:
QTimer *m_autoScaleTimer;
QList<PlotChannel *> m_channels;
bool m_xAxis;
};
} // namespace scopy::grutil
#endif // TIMEYAUTOSCALE_H
} // namespace scopy::gui
#endif // PLOTAUTOSCALER_H
Loading
Loading