1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-05-28 21:12:26 -04:00

Spectrum Markers: tri-state show marker state

This commit is contained in:
f4exb 2022-01-22 06:10:57 +01:00
parent 5abca451c9
commit 639373f7eb
11 changed files with 98 additions and 50 deletions

View File

@ -80,7 +80,7 @@ QByteArray SpectrumWaterfallMarker::serialize() const
s.writeS32(4, r); s.writeS32(4, r);
s.writeS32(5, g); s.writeS32(5, g);
s.writeS32(6, b); s.writeS32(6, b);
s.writeBool(7, m_show); s.writeS32(7, (int) m_show);
return s.final(); return s.final();
} }
@ -141,6 +141,8 @@ bool SpectrumAnnotationMarker::deserialize(const QByteArray& data)
if (d.getVersion() == 1) if (d.getVersion() == 1)
{ {
int tmp;
d.readS64(1, &m_startFrequency, 0); d.readS64(1, &m_startFrequency, 0);
d.readU32(2, &m_bandwidth, 0); d.readU32(2, &m_bandwidth, 0);
int r, g, b; int r, g, b;
@ -150,7 +152,8 @@ bool SpectrumAnnotationMarker::deserialize(const QByteArray& data)
m_markerColor.setGreen(g); m_markerColor.setGreen(g);
d.readS32(6, &b, 255); d.readS32(6, &b, 255);
m_markerColor.setBlue(b); m_markerColor.setBlue(b);
d.readBool(7, &m_show, true); d.readS32 (7, &tmp, 1);
m_show = (ShowState) tmp;
d.readString(8, &m_text); d.readString(8, &m_text);
return true; return true;

View File

@ -157,12 +157,18 @@ struct SDRBASE_API SpectrumWaterfallMarker
struct SDRBASE_API SpectrumAnnotationMarker struct SDRBASE_API SpectrumAnnotationMarker
{ {
enum ShowState
{
Hidden,
ShowTop,
ShowFull
};
qint64 m_startFrequency; qint64 m_startFrequency;
uint32_t m_bandwidth; uint32_t m_bandwidth;
QColor m_markerColor; QColor m_markerColor;
bool m_show; ShowState m_show;
QString m_text; QString m_text;
bool m_selected;
float m_startPos; float m_startPos;
float m_stopPos; float m_stopPos;
@ -170,9 +176,8 @@ struct SDRBASE_API SpectrumAnnotationMarker
m_startFrequency(0), m_startFrequency(0),
m_bandwidth(0), m_bandwidth(0),
m_markerColor("white"), m_markerColor("white"),
m_show(true), m_show(ShowTop),
m_text("Text"), m_text("Text"),
m_selected(false),
m_startPos(0.0f), m_startPos(0.0f),
m_stopPos(1.0f) m_stopPos(1.0f)
{} {}
@ -181,7 +186,7 @@ struct SDRBASE_API SpectrumAnnotationMarker
qint64 startFrequency, qint64 startFrequency,
uint32_t bandwidth, uint32_t bandwidth,
QColor markerColor, QColor markerColor,
bool show, ShowState show,
const QString& text const QString& text
) : ) :
m_startFrequency(startFrequency), m_startFrequency(startFrequency),

View File

@ -301,7 +301,7 @@ void SpectrumSettings::formatTo(SWGSDRangel::SWGObject *swgObject) const
swgSpectrum->getAnnotationMarkers()->back()->setStartFrequency(marker.m_startFrequency); swgSpectrum->getAnnotationMarkers()->back()->setStartFrequency(marker.m_startFrequency);
swgSpectrum->getAnnotationMarkers()->back()->setBandwidth(marker.m_bandwidth); swgSpectrum->getAnnotationMarkers()->back()->setBandwidth(marker.m_bandwidth);
swgSpectrum->getAnnotationMarkers()->back()->setMarkerColor(qColorToInt(marker.m_markerColor)); swgSpectrum->getAnnotationMarkers()->back()->setMarkerColor(qColorToInt(marker.m_markerColor));
swgSpectrum->getAnnotationMarkers()->back()->setShow(marker.m_show ? 1 : 0); swgSpectrum->getAnnotationMarkers()->back()->setShow((int) marker.m_show);
} }
} }
} }
@ -447,7 +447,7 @@ void SpectrumSettings::updateFrom(const QStringList& keys, const SWGSDRangel::SW
m_annoationMarkers.back().m_startFrequency = swgAnnotationMarker->getStartFrequency(); m_annoationMarkers.back().m_startFrequency = swgAnnotationMarker->getStartFrequency();
m_annoationMarkers.back().m_bandwidth = swgAnnotationMarker->getBandwidth() < 0 ? 0 : swgAnnotationMarker->getBandwidth(); m_annoationMarkers.back().m_bandwidth = swgAnnotationMarker->getBandwidth() < 0 ? 0 : swgAnnotationMarker->getBandwidth();
m_annoationMarkers.back().m_markerColor = intToQColor(swgAnnotationMarker->getMarkerColor()); m_annoationMarkers.back().m_markerColor = intToQColor(swgAnnotationMarker->getMarkerColor());
m_annoationMarkers.back().m_show = swgAnnotationMarker->getShow() != 0; m_annoationMarkers.back().m_show = (SpectrumAnnotationMarker::ShowState) swgAnnotationMarker->getShow();
} }
} }
} }

View File

@ -11804,7 +11804,7 @@ margin-bottom: 20px;
}, },
"show" : { "show" : {
"type" : "integer", "type" : "integer",
"description" : "Boolean - Marker display state\n * 0 - Hidden\n * 1 - Visible\n" "description" : "SpectrumAnnotationMarker::ShowState - Marker display state\n * 0 - Hidden\n * 1 - Only top marker visible\n * 2 - Fully visible with text and full sized limits\n"
} }
}, },
"description" : "Spectrum annotation marker settings" "description" : "Spectrum annotation marker settings"
@ -51969,7 +51969,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2022-01-15T23:01:29.100+01:00 Generated 2022-01-21T22:15:59.334+01:00
</div> </div>
</div> </div>
</div> </div>

View File

@ -59,9 +59,10 @@ SpectrumAnnotationMarker:
show: show:
type: integer type: integer
description: > description: >
Boolean - Marker display state SpectrumAnnotationMarker::ShowState - Marker display state
* 0 - Hidden * 0 - Hidden
* 1 - Visible * 1 - Only top marker visible
* 2 - Fully visible with text and full sized limits
GLSpectrum: GLSpectrum:
description: GLSpectrumGUI settings description: GLSpectrumGUI settings

View File

@ -1406,7 +1406,11 @@ void GLSpectrum::drawAnnotationMarkers()
for (const auto &marker : m_visibleAnnotationMarkers) for (const auto &marker : m_visibleAnnotationMarkers)
{ {
QVector4D color(marker->m_markerColor.redF(), marker->m_markerColor.greenF(), marker->m_markerColor.blueF(), 0.5f); if (marker->m_show == SpectrumAnnotationMarker::Hidden) {
continue;
}
QVector4D color(marker->m_markerColor.redF(), marker->m_markerColor.greenF(), marker->m_markerColor.blueF(), 0.5f);
if (marker->m_bandwidth == 0) if (marker->m_bandwidth == 0)
{ {
@ -1427,7 +1431,7 @@ void GLSpectrum::drawAnnotationMarkers()
m_glShaderSimple.drawSurface(m_glHistogramBoxMatrix, color, q3, 4); m_glShaderSimple.drawSurface(m_glHistogramBoxMatrix, color, q3, 4);
} }
if (marker->m_selected) if (marker->m_show == SpectrumAnnotationMarker::ShowFull)
{ {
QVector4D color( QVector4D color(
marker->m_markerColor.redF(), marker->m_markerColor.redF(),
@ -2283,7 +2287,6 @@ void GLSpectrum::updateSortedAnnotationMarkers()
if ((startPos > 1.0f) || (stopPos < 0.0f)) // out of range if ((startPos > 1.0f) || (stopPos < 0.0f)) // out of range
{ {
marker->m_selected = false;
continue; continue;
} }
@ -2579,18 +2582,19 @@ void GLSpectrum::mousePressEvent(QMouseEvent* event)
for (auto iMarker = m_visibleAnnotationMarkers.rbegin(); iMarker != m_visibleAnnotationMarkers.rend(); ++iMarker) for (auto iMarker = m_visibleAnnotationMarkers.rbegin(); iMarker != m_visibleAnnotationMarkers.rend(); ++iMarker)
{ {
if ((*iMarker)->m_show == SpectrumAnnotationMarker::Hidden) {
continue;
}
qint64 stopFrequency = (*iMarker)->m_startFrequency + qint64 stopFrequency = (*iMarker)->m_startFrequency +
((*iMarker)->m_bandwidth == 0 ? m_frequencyScale.getRange()*0.01f : (*iMarker)->m_bandwidth); ((*iMarker)->m_bandwidth == 0 ? m_frequencyScale.getRange()*0.01f : (*iMarker)->m_bandwidth);
if (((*iMarker)->m_startFrequency < selectedFrequency) && (selectedFrequency <= stopFrequency) && !selected) if (((*iMarker)->m_startFrequency < selectedFrequency) && (selectedFrequency <= stopFrequency) && !selected)
{ {
(*iMarker)->m_selected = true; (*iMarker)->m_show = (*iMarker)->m_show == SpectrumAnnotationMarker::ShowFull ?
SpectrumAnnotationMarker::ShowTop : SpectrumAnnotationMarker::ShowFull;
selected = true; selected = true;
} }
else
{
(*iMarker)->m_selected = false;
}
} }
} }

View File

@ -176,7 +176,7 @@ void SpectrumMarkersDialog::displayAnnotationMarker()
ui->aMarkerFrequency->blockSignals(true); ui->aMarkerFrequency->blockSignals(true);
ui->aCenterFrequency->blockSignals(true); ui->aCenterFrequency->blockSignals(true);
ui->aMarkerColor->blockSignals(true); ui->aMarkerColor->blockSignals(true);
ui->aShowMarker->blockSignals(true); ui->aMarkerShowState->blockSignals(true);
ui->aMarkerText->blockSignals(true); ui->aMarkerText->blockSignals(true);
ui->aMarker->blockSignals(true); ui->aMarker->blockSignals(true);
ui->aMarkerAdd->blockSignals(true); ui->aMarkerAdd->blockSignals(true);
@ -189,7 +189,7 @@ void SpectrumMarkersDialog::displayAnnotationMarker()
ui->aMarker->setEnabled(false); ui->aMarker->setEnabled(false);
ui->aMarkerFrequency->setEnabled(false); ui->aMarkerFrequency->setEnabled(false);
ui->aMarkerBandwidth->setEnabled(false); ui->aMarkerBandwidth->setEnabled(false);
ui->aShowMarker->setEnabled(false); ui->aMarkerShowState->setEnabled(false);
ui->aMarkerIndexText->setText("-"); ui->aMarkerIndexText->setText("-");
ui->aMarkerText->setText(""); ui->aMarkerText->setText("");
} }
@ -198,7 +198,7 @@ void SpectrumMarkersDialog::displayAnnotationMarker()
ui->aMarker->setEnabled(true); ui->aMarker->setEnabled(true);
ui->aMarkerFrequency->setEnabled(true); ui->aMarkerFrequency->setEnabled(true);
ui->aMarkerBandwidth->setEnabled(true); ui->aMarkerBandwidth->setEnabled(true);
ui->aShowMarker->setEnabled(true); ui->aMarkerShowState->setEnabled(true);
ui->aMarker->setValue(m_annotationMarkerIndex); ui->aMarker->setValue(m_annotationMarkerIndex);
ui->aMarkerIndexText->setText(tr("%1").arg(m_annotationMarkerIndex)); ui->aMarkerIndexText->setText(tr("%1").arg(m_annotationMarkerIndex));
qint64 frequency = m_annotationMarkers[m_annotationMarkerIndex].m_startFrequency + qint64 frequency = m_annotationMarkers[m_annotationMarkerIndex].m_startFrequency +
@ -215,6 +215,7 @@ void SpectrumMarkersDialog::displayAnnotationMarker()
m_annotationMarkers[m_annotationMarkerIndex].m_markerColor.getRgb(&r, &g, &b, &a); m_annotationMarkers[m_annotationMarkerIndex].m_markerColor.getRgb(&r, &g, &b, &a);
ui->aMarkerColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b)); ui->aMarkerColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b));
ui->aMarkerText->setText(tr("%1").arg(m_annotationMarkers[m_annotationMarkerIndex].m_text)); ui->aMarkerText->setText(tr("%1").arg(m_annotationMarkers[m_annotationMarkerIndex].m_text));
ui->aMarkerShowState->setCurrentIndex((int) m_annotationMarkers[m_annotationMarkerIndex].m_show);
} }
ui->aMarkerToggleFrequency->setChecked(m_annoFreqStartElseCenter); ui->aMarkerToggleFrequency->setChecked(m_annoFreqStartElseCenter);
@ -222,7 +223,7 @@ void SpectrumMarkersDialog::displayAnnotationMarker()
ui->aMarkerFrequency->blockSignals(false); ui->aMarkerFrequency->blockSignals(false);
ui->aCenterFrequency->blockSignals(false); ui->aCenterFrequency->blockSignals(false);
ui->aMarkerColor->blockSignals(false); ui->aMarkerColor->blockSignals(false);
ui->aShowMarker->blockSignals(false); ui->aMarkerShowState->blockSignals(false);
ui->aMarkerText->blockSignals(false); ui->aMarkerText->blockSignals(false);
ui->aMarker->blockSignals(false); ui->aMarker->blockSignals(false);
ui->aMarkerAdd->blockSignals(false); ui->aMarkerAdd->blockSignals(false);
@ -613,13 +614,20 @@ void SpectrumMarkersDialog::on_aMarkerColor_clicked()
} }
} }
void SpectrumMarkersDialog::on_aShowMarker_clicked(bool clicked) void SpectrumMarkersDialog::on_aMarkerShowState_currentIndexChanged(int state)
{ {
if (m_annotationMarkers.size() == 0) { if (m_annotationMarkers.size() == 0) {
return; return;
} }
m_annotationMarkers[m_annotationMarkerIndex].m_show = clicked; m_annotationMarkers[m_annotationMarkerIndex].m_show = (SpectrumAnnotationMarker::ShowState) state;
}
void SpectrumMarkersDialog::on_aMarkerShowStateAll_clicked()
{
for (auto &marker : m_annotationMarkers) {
marker.m_show = (SpectrumAnnotationMarker::ShowState) ui->aMarkerShowState->currentIndex();
}
} }
void SpectrumMarkersDialog::on_aMarkerText_editingFinished() void SpectrumMarkersDialog::on_aMarkerText_editingFinished()
@ -726,7 +734,7 @@ void SpectrumMarkersDialog::on_aMarkersImport_clicked()
m_annotationMarkers.back().m_startFrequency = cols[startCol].toLongLong(); m_annotationMarkers.back().m_startFrequency = cols[startCol].toLongLong();
m_annotationMarkers.back().m_bandwidth = cols[widthCol].toUInt(); m_annotationMarkers.back().m_bandwidth = cols[widthCol].toUInt();
m_annotationMarkers.back().m_text = cols[textCol]; m_annotationMarkers.back().m_text = cols[textCol];
m_annotationMarkers.back().m_show = cols[showCol].toInt() != 0; m_annotationMarkers.back().m_show = (SpectrumAnnotationMarker::ShowState) cols[showCol].toInt();
int r = cols[redCol].toInt(); int r = cols[redCol].toInt();
int g = cols[greenCol].toInt(); int g = cols[greenCol].toInt();
int b = cols[blueCol].toInt(); int b = cols[blueCol].toInt();

View File

@ -97,7 +97,8 @@ private slots:
void on_aMakerDuplicate_clicked(); void on_aMakerDuplicate_clicked();
void on_aMakersSort_clicked(); void on_aMakersSort_clicked();
void on_aMarkerColor_clicked(); void on_aMarkerColor_clicked();
void on_aShowMarker_clicked(bool clicked); void on_aMarkerShowState_currentIndexChanged(int state);
void on_aMarkerShowStateAll_clicked();
void on_aMarkerText_editingFinished(); void on_aMarkerText_editingFinished();
void on_aMarker_valueChanged(int value); void on_aMarker_valueChanged(int value);
void on_aMarkerAdd_clicked(); void on_aMarkerAdd_clicked();

View File

@ -29,7 +29,7 @@
<item> <item>
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="currentIndex"> <property name="currentIndex">
<number>2</number> <number>0</number>
</property> </property>
<widget class="QWidget" name="hisTab"> <widget class="QWidget" name="hisTab">
<attribute name="title"> <attribute name="title">
@ -1035,7 +1035,7 @@
<widget class="QLabel" name="aMarkerIndexText"> <widget class="QLabel" name="aMarkerIndexText">
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>15</width> <width>30</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -1046,7 +1046,7 @@
<string>0</string> <string>0</string>
</property> </property>
<property name="alignment"> <property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property> </property>
</widget> </widget>
</item> </item>
@ -1216,26 +1216,13 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QCheckBox" name="aShowMarker">
<property name="toolTip">
<string>Show this marker</string>
</property>
<property name="text">
<string/>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item> <item>
<widget class="QLineEdit" name="aMarkerText"> <widget class="QLineEdit" name="aMarkerText">
<property name="toolTip"> <property name="toolTip">
<string>Marker text</string> <string>Marker text</string>
</property> </property>
<property name="maxLength"> <property name="maxLength">
<number>30</number> <number>36</number>
</property> </property>
</widget> </widget>
</item> </item>
@ -1640,6 +1627,44 @@
</property> </property>
</widget> </widget>
</item> </item>
<item>
<widget class="QComboBox" name="aMarkerShowState">
<property name="toolTip">
<string>Marker show state</string>
</property>
<item>
<property name="text">
<string>Hidden</string>
</property>
</item>
<item>
<property name="text">
<string>Top</string>
</property>
</item>
<item>
<property name="text">
<string>Full</string>
</property>
</item>
</widget>
</item>
<item>
<widget class="QPushButton" name="aMarkerShowStateAll">
<property name="maximumSize">
<size>
<width>30</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip">
<string>Apply current show state to all markers</string>
</property>
<property name="text">
<string>All</string>
</property>
</widget>
</item>
<item> <item>
<spacer name="horizontalSpacer_7"> <spacer name="horizontalSpacer_7">
<property name="orientation"> <property name="orientation">

View File

@ -59,9 +59,10 @@ SpectrumAnnotationMarker:
show: show:
type: integer type: integer
description: > description: >
Boolean - Marker display state SpectrumAnnotationMarker::ShowState - Marker display state
* 0 - Hidden * 0 - Hidden
* 1 - Visible * 1 - Only top marker visible
* 2 - Fully visible with text and full sized limits
GLSpectrum: GLSpectrum:
description: GLSpectrumGUI settings description: GLSpectrumGUI settings

View File

@ -11804,7 +11804,7 @@ margin-bottom: 20px;
}, },
"show" : { "show" : {
"type" : "integer", "type" : "integer",
"description" : "Boolean - Marker display state\n * 0 - Hidden\n * 1 - Visible\n" "description" : "SpectrumAnnotationMarker::ShowState - Marker display state\n * 0 - Hidden\n * 1 - Only top marker visible\n * 2 - Fully visible with text and full sized limits\n"
} }
}, },
"description" : "Spectrum annotation marker settings" "description" : "Spectrum annotation marker settings"
@ -51969,7 +51969,7 @@ except ApiException as e:
</div> </div>
<div id="generator"> <div id="generator">
<div class="content"> <div class="content">
Generated 2022-01-15T23:01:29.100+01:00 Generated 2022-01-21T22:15:59.334+01:00
</div> </div>
</div> </div>
</div> </div>