Skip to content

Commit bcc723b

Browse files
Jacob Gilbertjacobagilbert
authored andcommitted
adding explicit control for SigMF Labels
Signed-off-by: Jacob Gilbert <jacobgilbert@protonmail.com>
1 parent 4c17364 commit bcc723b

File tree

7 files changed

+28
-5
lines changed

7 files changed

+28
-5
lines changed

src/mainwindow.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ MainWindow::MainWindow()
5252
connect(dock->scalesCheckBox, &QCheckBox::stateChanged, plots, &PlotView::enableScales);
5353
connect(dock->annosCheckBox, &QCheckBox::stateChanged, plots, &PlotView::enableAnnotations);
5454
connect(dock->annosCheckBox, &QCheckBox::stateChanged, dock, &SpectrogramControls::enableAnnotations);
55+
connect(dock->annoLabelCheckBox, &QCheckBox::stateChanged, plots, &PlotView::enableAnnoLabels);
5556
connect(dock->commentsCheckBox, &QCheckBox::stateChanged, plots, &PlotView::enableAnnotationCommentsTooltips);
5657
connect(dock->annoColorCheckBox, &QCheckBox::stateChanged, plots, &PlotView::enableAnnoColors);
5758
connect(dock->cursorSymbolsSpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), plots, &PlotView::setCursorSegments);

src/plotview.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ PlotView::PlotView(InputSource *input) : cursors(this), viewRange({0, 0})
5252
enableScales(true);
5353

5454
enableAnnotations(true);
55-
enableAnnotationCommentsTooltips(true);
56-
55+
enableAnnoLabels(true);
5756
enableAnnoColors(true);
57+
enableAnnotationCommentsTooltips(true);
5858

5959
addPlot(spectrogramPlot);
6060

@@ -666,6 +666,14 @@ void PlotView::enableAnnotations(bool enabled)
666666
viewport()->update();
667667
}
668668

669+
void PlotView::enableAnnoLabels(bool enabled)
670+
{
671+
if (spectrogramPlot != nullptr)
672+
spectrogramPlot->enableAnnoLabels(enabled);
673+
674+
viewport()->update();
675+
}
676+
669677
void PlotView::enableAnnotationCommentsTooltips(bool enabled)
670678
{
671679
annotationCommentsEnabled = enabled;

src/plotview.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ public slots:
4747
void enableCursors(bool enabled);
4848
void enableScales(bool enabled);
4949
void enableAnnotations(bool enabled);
50+
void enableAnnoLabels(bool enabled);
5051
void enableAnnotationCommentsTooltips(bool enabled);
5152
void enableAnnoColors(bool enabled);
5253
void invalidateEvent() override;

src/spectrogramcontrols.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ SpectrogramControls::SpectrogramControls(const QString & title, QWidget * parent
9999

100100
annosCheckBox = new QCheckBox(widget);
101101
layout->addRow(new QLabel(tr("Display Annotations:")), annosCheckBox);
102+
annoLabelCheckBox = new QCheckBox(widget);
103+
layout->addRow(new QLabel(tr("Annotation Labels:")), annoLabelCheckBox);
102104
commentsCheckBox = new QCheckBox(widget);
103105
layout->addRow(new QLabel(tr("Annotation comments:")), commentsCheckBox);
104106
annoColorCheckBox = new QCheckBox(widget);
@@ -138,6 +140,7 @@ void SpectrogramControls::setDefaults()
138140
cursorSymbolsSpinBox->setValue(1);
139141

140142
annosCheckBox->setCheckState(Qt::Checked);
143+
annoLabelCheckBox->setCheckState(Qt::Checked);
141144
annoColorCheckBox->setCheckState(Qt::Checked);
142145

143146
// Try to set the sample rate from the last-used value

src/spectrogramcontrols.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ private slots:
7575
QLabel *symbolPeriodLabel;
7676
QCheckBox *scalesCheckBox;
7777
QCheckBox *annosCheckBox;
78+
QCheckBox *annoLabelCheckBox;
7879
QCheckBox *commentsCheckBox;
7980
QCheckBox *annoColorCheckBox;
8081
};

src/spectrogramplot.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ SpectrogramPlot::SpectrogramPlot(std::shared_ptr<SampleSource<std::complex<float
4343
sampleRate = 0;
4444
frequencyScaleEnabled = false;
4545
sigmfAnnotationsEnabled = true;
46+
sigmfAnnotationLabels = true;
4647
sigmfAnnotationColors = true;
4748

4849
for (int i = 0; i < 256; i++) {
@@ -201,9 +202,10 @@ void SpectrogramPlot::paintAnnotations(QPainter &painter, QRect &rect, range_t<s
201202
if (sigmfAnnotationColors) {
202203
painter.setPen(a.boxColor);
203204
}
204-
205-
// Draw the label 2 pixels above the box
206-
painter.drawText(x, y - 2, a.label);
205+
if (sigmfAnnotationLabels) {
206+
// Draw the label 2 pixels above the box
207+
painter.drawText(x, y - 2, a.label);
208+
}
207209
painter.drawRect(x, y, width, height);
208210

209211
visibleAnnotationLocations.emplace_back(a, x, y, width, height);
@@ -436,6 +438,11 @@ bool SpectrogramPlot::isAnnotationsEnabled(void)
436438
return sigmfAnnotationsEnabled;
437439
}
438440

441+
void SpectrogramPlot::enableAnnoLabels(bool enabled)
442+
{
443+
sigmfAnnotationLabels = enabled;
444+
}
445+
439446
void SpectrogramPlot::enableAnnoColors(bool enabled)
440447
{
441448
sigmfAnnotationColors = enabled;

src/spectrogramplot.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class SpectrogramPlot : public Plot
5252
bool tunerEnabled();
5353
void enableScales(bool enabled);
5454
void enableAnnotations(bool enabled);
55+
void enableAnnoLabels(bool enabled);
5556
bool isAnnotationsEnabled();
5657
void enableAnnoColors(bool enabled);
5758
QString *mouseAnnotationComment(const QMouseEvent *event);
@@ -84,6 +85,7 @@ public slots:
8485
double sampleRate;
8586
bool frequencyScaleEnabled;
8687
bool sigmfAnnotationsEnabled;
88+
bool sigmfAnnotationLabels;
8789
bool sigmfAnnotationColors;
8890

8991
Tuner tuner;

0 commit comments

Comments
 (0)