Skip to content

Commit

Permalink
gui: PlotTracker: added plot status
Browse files Browse the repository at this point in the history
- created generic class for plot info labels

Signed-off-by: Andrei Popa <[email protected]>
  • Loading branch information
andrei47w committed May 7, 2024
1 parent 58afc89 commit e569399
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
4 changes: 4 additions & 0 deletions gr-util/src/grtimeplotaddon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ void GRTimePlotAddon::onStart()
m_top->build();
m_top->start();
m_started = true;

m_info->updateStatus("running");
}
}

Expand All @@ -258,6 +260,8 @@ void GRTimePlotAddon::onStop()
disconnect(m_top, SIGNAL(builtSignalPaths()), this, SLOT(connectSignalPaths()));
disconnect(m_top, SIGNAL(teardownSignalPaths()), this, SLOT(tearDownSignalPaths()));
m_started = false;

m_info->updateStatus("stopped");
}
}

Expand Down
19 changes: 6 additions & 13 deletions gui/include/gui/widgets/plotinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,20 +56,12 @@ public Q_SLOTS:
int m_avgSize;
};

class SCOPY_GUI_EXPORT TimePlotTimestamp : public QLabel
class SCOPY_GUI_EXPORT GenericInfoLabel : public QLabel
{
Q_OBJECT
public:
TimePlotTimestamp(QWidget *parent = nullptr);
virtual ~TimePlotTimestamp();
};

class SCOPY_GUI_EXPORT TimePlotStatusInfo : public QLabel
{
Q_OBJECT
public:
TimePlotStatusInfo(QWidget *parent = nullptr);
virtual ~TimePlotStatusInfo();
GenericInfoLabel(QWidget *parent = nullptr);
virtual ~GenericInfoLabel();
};

class SCOPY_GUI_EXPORT TimePlotVDivInfo : public QWidget
Expand All @@ -84,14 +76,15 @@ class SCOPY_GUI_EXPORT TimePlotInfo : public QWidget

public Q_SLOTS:
void update(PlotSamplingInfo info);
void updateStatus(QString status);

private:
PlotWidget *m_plot;
TimePlotHDivInfo *m_hdiv;
TimePlotSamplingInfo *m_sampling;
TimePlotStatusInfo *m_status;
GenericInfoLabel *m_status;
TimePlotFPS *m_fps;
TimePlotTimestamp *m_timestamp;
GenericInfoLabel *m_timestamp;
};

} // namespace scopy
Expand Down
30 changes: 15 additions & 15 deletions gui/src/widgets/plotinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,21 +74,13 @@ void TimePlotFPS::update(qint64 timestamp)
setText(QString(QString::number(1000. / avg, 'g', 3) + " FPS"));
}

TimePlotTimestamp::TimePlotTimestamp(QWidget *parent)
GenericInfoLabel::GenericInfoLabel(QWidget *parent)
{
StyleHelper::TimePlotSamplingInfo(this);
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
}

TimePlotTimestamp::~TimePlotTimestamp() {}

TimePlotStatusInfo::TimePlotStatusInfo(QWidget *parent)
{
setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
StyleHelper::TimePlotSamplingInfo(this);
}

TimePlotStatusInfo::~TimePlotStatusInfo() {}
GenericInfoLabel::~GenericInfoLabel() {}

TimePlotInfo::TimePlotInfo(PlotWidget *plot, QWidget *parent)
{
Expand All @@ -105,14 +97,12 @@ TimePlotInfo::TimePlotInfo(PlotWidget *plot, QWidget *parent)

m_hdiv = new TimePlotHDivInfo(this);
m_sampling = new TimePlotSamplingInfo(this);
m_status = new TimePlotStatusInfo(this);
m_status = new GenericInfoLabel(this);

m_fps = new TimePlotFPS(this);
connect(plot, &PlotWidget::newData, this, [=]() {
m_fps->update(QDateTime::currentMSecsSinceEpoch());
});
connect(plot, &PlotWidget::newData, this, [=]() { m_fps->update(QDateTime::currentMSecsSinceEpoch()); });

m_timestamp = new TimePlotTimestamp(this);
m_timestamp = new GenericInfoLabel(this);
connect(plot, &PlotWidget::newData, this,
[=]() { m_timestamp->setText(QDateTime::currentDateTime().time().toString("hh:mm:ss.zzz")); });

Expand Down Expand Up @@ -161,6 +151,14 @@ TimePlotInfo::TimePlotInfo(PlotWidget *plot, QWidget *parent)
timestampHover->setAnchorOffset(QPoint(-8, 26));
timestampHover->show();
timestampHover->setAttribute(Qt::WA_TransparentForMouseEvents);

HoverWidget *statusHover = new HoverWidget(nullptr, plot->plot()->canvas(), plot->plot());
statusHover->setContent(m_status);
statusHover->setAnchorPos(HoverPosition::HP_TOPRIGHT);
statusHover->setContentPos(HoverPosition::HP_BOTTOMLEFT);
statusHover->setAnchorOffset(QPoint(-8, 46));
statusHover->show();
statusHover->setAttribute(Qt::WA_TransparentForMouseEvents);
#endif
}

Expand All @@ -183,4 +181,6 @@ void TimePlotInfo::update(PlotSamplingInfo info)
m_sampling->update(info.plotSize, info.bufferSize, info.sampleRate);
}

void TimePlotInfo::updateStatus(QString status) { m_status->setText(status); }

#include "moc_plotinfo.cpp"

0 comments on commit e569399

Please sign in to comment.