Spectrum markers: implemented colors etc...

pull/983/head
f4exb 2021-08-01 20:26:24 +02:00
rodzic e7e82a12b0
commit 133f6caa60
5 zmienionych plików z 125 dodań i 31 usunięć

Wyświetl plik

@ -1163,8 +1163,7 @@ void GLSpectrum::paintGL()
void GLSpectrum::drawMarkers()
{
QVector4D markerColor(1.0f, 1.0f, 1.0f, 0.3f);
QVector4D markerTextColor(1.0f, 1.0f, 1.0f, 0.8f);
QVector4D lineColor(1.0f, 1.0f, 1.0f, 0.3f);
// paint histogram markers
if (m_histogramMarkers.size() > 0)
@ -1178,7 +1177,9 @@ void GLSpectrum::drawMarkers()
{
ypoint.ry() =
(m_powerScale.getRangeMax() - m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin]) / m_powerScale.getRange();
ypoint.ry() = ypoint.ry() > 1 ? 1 : ypoint.ry();
ypoint.ry() = ypoint.ry() < 0 ?
0 : ypoint.ry() > 1 ?
1 : ypoint.ry();
powerStr = displayScaledF(
m_currentSpectrum[m_histogramMarkers.at(i).m_fftBin],
m_linear ? 'e' : 'f',
@ -1192,18 +1193,19 @@ void GLSpectrum::drawMarkers()
(float) m_histogramMarkers.at(i).m_point.x(), 0,
(float) m_histogramMarkers.at(i).m_point.x(), 1
};
m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, h, 2);
m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, lineColor, h, 2);
GLfloat v[] {
0, (float) ypoint.y(),
1, (float) ypoint.y()
};
m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, markerColor, v, 2);
m_glShaderSimple.drawSegments(m_glHistogramBoxMatrix, lineColor, v, 2);
QColor textColor = m_histogramMarkers.at(i).m_markerColor;
// text
if (i == 0)
{
drawTextOverlay(
m_histogramMarkers.at(i).m_frequencyStr,
QColor(255, 255, 255, 192),
textColor,
m_textOverlayFont,
m_histogramMarkers.at(i).m_point.x() * m_histogramRect.width(),
(m_invertedWaterfall || (m_waterfallHeight == 0)) ? m_histogramRect.height() : 0,
@ -1212,7 +1214,7 @@ void GLSpectrum::drawMarkers()
m_histogramRect);
drawTextOverlay(
powerStr,
QColor(255, 255, 255, 192),
textColor,
m_textOverlayFont,
0,
ypoint.y() * m_histogramRect.height(),
@ -1222,6 +1224,7 @@ void GLSpectrum::drawMarkers()
}
else
{
textColor.setAlpha(192);
float power0 = m_histogramMarkers.at(0).m_markerType == SpectrumHistogramMarkerTypePower ?
m_currentSpectrum[m_histogramMarkers.at(0).m_fftBin] :
m_linear ? m_histogramMarkers.at(0).m_power : CalcDb::dbPower(m_histogramMarkers.at(0).m_power);
@ -1238,7 +1241,7 @@ void GLSpectrum::drawMarkers()
drawTextOverlay(
m_histogramMarkers.at(i).m_deltaFrequencyStr,
QColor(255, 255, 255, 192),
textColor,
m_textOverlayFont,
m_histogramMarkers.at(i).m_point.x() * m_histogramRect.width(),
(m_invertedWaterfall || (m_waterfallHeight == 0)) ? 0 : m_histogramRect.height(),
@ -1247,7 +1250,7 @@ void GLSpectrum::drawMarkers()
m_histogramRect);
drawTextOverlay(
deltaPowerStr,
QColor(255, 255, 255, 192),
textColor,
m_textOverlayFont,
m_histogramRect.width(),
ypoint.y() * m_histogramRect.height(),
@ -1268,21 +1271,24 @@ void GLSpectrum::drawMarkers()
(float) m_waterfallMarkers.at(i).m_point.x(), 0,
(float) m_waterfallMarkers.at(i).m_point.x(), 1
};
m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, markerColor, h, 2);
m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, lineColor, h, 2);
GLfloat v[] {
0, (float) m_waterfallMarkers.at(i).m_point.y(),
1, (float) m_waterfallMarkers.at(i).m_point.y()
};
m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, markerColor, v, 2);
m_glShaderSimple.drawSegments(m_glWaterfallBoxMatrix, lineColor, v, 2);
}
// text
for (int i = 0; i < m_waterfallMarkers.size(); i++)
{
QColor textColor = m_waterfallMarkers.at(i).m_markerColor;
textColor.setAlpha(192);
if (i == 0)
{
drawTextOverlay(
m_waterfallMarkers.at(i).m_frequencyStr,
QColor(255, 255, 255, 192),
textColor,
m_textOverlayFont,
m_waterfallMarkers.at(i).m_point.x() * m_waterfallRect.width(),
(!m_invertedWaterfall || (m_histogramHeight == 0)) ? m_waterfallRect.height() : 0,
@ -1291,7 +1297,7 @@ void GLSpectrum::drawMarkers()
m_waterfallRect);
drawTextOverlay(
m_waterfallMarkers.at(i).m_timeStr,
QColor(255, 255, 255, 192),
textColor,
m_textOverlayFont,
0,
m_waterfallMarkers.at(i).m_point.y() * m_waterfallRect.height(),
@ -1303,7 +1309,7 @@ void GLSpectrum::drawMarkers()
{
drawTextOverlay(
m_waterfallMarkers.at(i).m_deltaFrequencyStr,
QColor(255, 255, 255, 192),
textColor,
m_textOverlayFont,
m_waterfallMarkers.at(i).m_point.x() * m_waterfallRect.width(),
(!m_invertedWaterfall || (m_histogramHeight == 0)) ? 0 : m_waterfallRect.height(),
@ -1312,7 +1318,7 @@ void GLSpectrum::drawMarkers()
m_waterfallRect);
drawTextOverlay(
m_waterfallMarkers.at(i).m_deltaTimeStr,
QColor(255, 255, 255, 192),
textColor,
m_textOverlayFont,
m_waterfallRect.width(),
m_waterfallMarkers.at(i).m_point.y() * m_waterfallRect.height(),

Wyświetl plik

@ -23,6 +23,7 @@
#include <QString>
#include <QPointF>
#include <QColor>
enum SpectrumHistogramMarkerType {
SpectrumHistogramMarkerTypeManual,
@ -36,6 +37,7 @@ struct SpectrumHistogramMarker
int m_fftBin;
float m_power;
SpectrumHistogramMarkerType m_markerType;
QColor m_markerColor;
QString m_frequencyStr;
QString m_powerStr;
QString m_deltaFrequencyStr;
@ -48,6 +50,7 @@ struct SpectrumHistogramMarker
m_fftBin(0),
m_power(0),
m_markerType(SpectrumHistogramMarkerTypeManual),
m_markerColor(QColorConstants::White),
m_frequencyStr(),
m_powerStr(),
m_deltaFrequencyStr(),
@ -60,6 +63,7 @@ struct SpectrumHistogramMarker
int fftBin,
float power,
SpectrumHistogramMarkerType markerType,
QColor markerColor,
const QString& frequencyStr,
const QString& powerStr,
const QString& deltaFrequencyStr,
@ -70,6 +74,7 @@ struct SpectrumHistogramMarker
m_fftBin(fftBin),
m_power(power),
m_markerType(markerType),
m_markerColor(markerColor),
m_frequencyStr(frequencyStr),
m_powerStr(powerStr),
m_deltaFrequencyStr(deltaFrequencyStr),
@ -85,6 +90,7 @@ struct SpectrumWaterfallMarker
QPointF m_point;
float m_frequency;
float m_time;
QColor m_markerColor;
QString m_frequencyStr;
QString m_timeStr;
QString m_deltaFrequencyStr;
@ -95,6 +101,7 @@ struct SpectrumWaterfallMarker
m_point(0, 0),
m_frequency(0),
m_time(0),
m_markerColor(QColorConstants::White),
m_frequencyStr(),
m_timeStr(),
m_deltaFrequencyStr(),
@ -105,6 +112,7 @@ struct SpectrumWaterfallMarker
const QPointF& point,
float frequency,
float time,
QColor markerColor,
const QString& frequencyStr,
const QString& timeStr,
const QString& deltaFrequencyStr,
@ -113,6 +121,7 @@ struct SpectrumWaterfallMarker
m_point(point),
m_frequency(frequency),
m_time(time),
m_markerColor(markerColor),
m_frequencyStr(frequencyStr),
m_timeStr(timeStr),
m_deltaFrequencyStr(deltaFrequencyStr),

Wyświetl plik

@ -16,6 +16,8 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>. //
///////////////////////////////////////////////////////////////////////////////////
#include <QColorDialog>
#include "util/db.h"
#include "spectrummarkersdialog.h"
@ -68,6 +70,9 @@ void SpectrumMarkersDialog::displayHistogramMarker()
float powerDB = CalcDb::dbPower(m_histogramMarkers[m_histogramMarkerIndex].m_power);
ui->fixedPower->setValue(powerDB*10);
ui->fixedPowerText->setText(QString::number(powerDB, 'f', 1));
int r,g,b,a;
m_histogramMarkers[m_histogramMarkerIndex].m_markerColor.getRgb(&r, &g, &b, &a);
ui->markerColor->setStyleSheet(tr("QLabel { background-color : rgb(%1,%2,%3); }").arg(r).arg(g).arg(b));
}
}
@ -81,6 +86,37 @@ void SpectrumMarkersDialog::on_markerFrequency_changed(qint64 value)
emit updateHistogram();
}
void SpectrumMarkersDialog::on_centerFrequency_clicked()
{
if (m_histogramMarkers.size() == 0) {
return;
}
m_histogramMarkers[m_histogramMarkerIndex].m_frequency = m_centerFrequency;
displayHistogramMarker();
emit updateHistogram();
}
void SpectrumMarkersDialog::on_markerColor_clicked()
{
if (m_histogramMarkers.size() == 0) {
return;
}
QColor newColor = QColorDialog::getColor(
m_histogramMarkers[m_histogramMarkerIndex].m_markerColor,
this,
tr("Select Color for marker"),
QColorDialog::DontUseNativeDialog
);
if (newColor.isValid()) // user clicked OK and selected a color
{
m_histogramMarkers[m_histogramMarkerIndex].m_markerColor = newColor;
displayHistogramMarker();
}
}
void SpectrumMarkersDialog::on_fixedPower_valueChanged(int value)
{
if (m_histogramMarkers.size() == 0) {
@ -103,25 +139,25 @@ void SpectrumMarkersDialog::on_marker_valueChanged(int value)
displayHistogramMarker();
}
void SpectrumMarkersDialog::on_setReference_clicked(bool checked)
void SpectrumMarkersDialog::on_setReference_clicked()
{
(void) checked;
if ((m_histogramMarkerIndex == 0) || (m_histogramMarkers.size() < 2)) {
return;
}
SpectrumHistogramMarker marker0 = m_histogramMarkers.at(0);
QColor color0 = marker0.m_markerColor; // do not exchange colors
QColor colorI = m_histogramMarkers[m_histogramMarkerIndex].m_markerColor;
m_histogramMarkers[0] = m_histogramMarkers[m_histogramMarkerIndex];
m_histogramMarkers[0].m_markerColor = color0;
m_histogramMarkers[m_histogramMarkerIndex] = marker0;
m_histogramMarkers[m_histogramMarkerIndex].m_markerColor = colorI;
displayHistogramMarker();
emit updateHistogram();
}
void SpectrumMarkersDialog::on_markerAdd_clicked(bool checked)
void SpectrumMarkersDialog::on_markerAdd_clicked()
{
(void) checked;
if (m_histogramMarkers.size() == SpectrumHistogramMarker::m_maxNbOfMarkers) {
return;
}
@ -134,10 +170,8 @@ void SpectrumMarkersDialog::on_markerAdd_clicked(bool checked)
displayHistogramMarker();
}
void SpectrumMarkersDialog::on_markerDel_clicked(bool checked)
void SpectrumMarkersDialog::on_markerDel_clicked()
{
(void) checked;
if (m_histogramMarkers.size() == 0) {
return;
}

Wyświetl plik

@ -54,11 +54,13 @@ private:
private slots:
void on_markerFrequency_changed(qint64 value);
void on_centerFrequency_clicked();
void on_markerColor_clicked();
void on_fixedPower_valueChanged(int value);
void on_marker_valueChanged(int value);
void on_setReference_clicked(bool checked);
void on_markerAdd_clicked(bool checked);
void on_markerDel_clicked(bool checked);
void on_setReference_clicked();
void on_markerAdd_clicked();
void on_markerDel_clicked();
void on_powerMode_currentIndexChanged(int index);
signals:

Wyświetl plik

@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>324</width>
<width>364</width>
<height>125</height>
</rect>
</property>
@ -23,7 +23,7 @@
<item>
<layout class="QVBoxLayout" name="MarkerLayout">
<item>
<layout class="QHBoxLayout" name="MarkerPosLayout">
<layout class="QHBoxLayout" name="HMarkerPosLayout">
<item>
<widget class="QLabel" name="markerFrequencyLabel">
<property name="text">
@ -103,10 +103,48 @@
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="centerFrequency">
<property name="maximumSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
<property name="toolTip">
<string>Set marker as reference (index 0)</string>
</property>
<property name="text">
<string>C</string>
</property>
</widget>
</item>
<item>
<widget class="ClickableLabel" name="markerColor">
<property name="minimumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="toolTip">
<string>Current marker color (click to change)</string>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="OptionsLayout">
<layout class="QHBoxLayout" name="HMarkerOptionsLayout">
<item>
<widget class="QLabel" name="markerLabel">
<property name="minimumSize">
@ -167,7 +205,7 @@
<string>Set marker as reference (index 0)</string>
</property>
<property name="text">
<string>R</string>
<string>0</string>
</property>
</widget>
</item>
@ -406,6 +444,11 @@
<header>gui/valuedialz.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>ClickableLabel</class>
<extends>QLabel</extends>
<header>gui/clickablelabel.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>buttonBox</tabstop>