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

Multiple independent bandmap windows #593

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/macOSBuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
name: MacOS Build
strategy:
matrix:
os: [macos-12, macos-13]
os: [macos-12, macos-14]

runs-on: ${{ matrix.os }}

Expand Down
2 changes: 1 addition & 1 deletion core/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ int main(int argc, char* argv[])
QIcon icon(":/res/qlog.png");
splash.finish(&w);
w.setWindowIcon(icon);

QObject::connect(&app, &QCoreApplication::aboutToQuit, &w, &MainWindow::aboutToQuit);
w.show();
#ifdef Q_OS_OSX
w.setLayoutGeometry();
Expand Down
127 changes: 99 additions & 28 deletions ui/BandmapWidget.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsTextItem>
#include <QMutableMapIterator>
#include <QMenu>
#include <QTextDocument>
#include <QMutableMapIterator>
#include <QScrollBar>
#include <QGraphicsSceneMouseEvent>
#include <algorithm>
#include <QTextDocument>
#include <QWheelEvent>
#include <algorithm>

#include "BandmapWidget.h"
#include "ui_BandmapWidget.h"
Expand All @@ -28,15 +28,18 @@ MODULE_IDENTIFICATION("qlog.ui.bandmapwidget");

#define WIDGET_CENTER ( height()/2 - 50 )

BandmapWidget::BandmapWidget(QWidget *parent) :
QWidget(parent),
ui(new Ui::BandmapWidget),
rxMark(nullptr),
txMark(nullptr),
keepRXCenter(true),
pendingSpots(0),
lastStationUpdate(0),
bandmapAnimation(true)
QMap<double, DxSpot> BandmapWidget::spots;

BandmapWidget::BandmapWidget(QWidget *parent, QString nonVfoWidgetId)
: QWidget(parent)
, ui(new Ui::BandmapWidget)
, rxMark(nullptr)
, txMark(nullptr)
, keepRXCenter(true)
, pendingSpots(0)
, lastStationUpdate(0)
, bandmapAnimation(true)
, isNonVfo(nonVfoWidgetId != nullptr)
{
FCT_IDENTIFICATION;

Expand All @@ -49,7 +52,27 @@ BandmapWidget::BandmapWidget(QWidget *parent) :
const QString &submode = settings.value("newcontact/submode").toString();
keepRXCenter = settings.value("bandmap/centerrx", true).toBool();

setBand(BandPlan::freq2Band(ritFreq), false);
if (isNonVfo) {
setObjectName(nonVfoWidgetId);
ui->bottomRow->setVisible(false);
ui->clearButton->setVisible(false);
// read the band for this window from persisted state (settings) or a new
// bandmap should start at the currently active vfo
Band startingBand = BandPlan::freq2Band(ritFreq);
QString nonVfoBandName = settings.value(nonVfoWidgetId).toString();
qCDebug(runtime) << nonVfoWidgetId << "band from settings" << nonVfoBandName;

for (const Band &enabledBand : BandPlan::bandsList(false, true)) {
if (enabledBand.name == nonVfoBandName) {
startingBand = enabledBand;
break;
}
}
setBand(startingBand);
} else {
ui->clearSpotOlderSpin->setValue(settings.value("bandmap/spot_aging", 0).toInt());
setBand(BandPlan::freq2Band(ritFreq), false);
}

bandmapScene = new GraphicsScene(this);
bandmapScene->setFocusOnTouch(false);
Expand All @@ -63,8 +86,6 @@ BandmapWidget::BandmapWidget(QWidget *parent) :
ui->graphicsView->installEventFilter(this);
//ui->scrollArea->verticalScrollBar()->setSingleStep(5);

ui->clearSpotOlderSpin->setValue(settings.value("bandmap/spot_aging", 0).toInt());

update_timer = new QTimer;
connect(update_timer, &QTimer::timeout, this, &BandmapWidget::updateStationTimer);
update_timer->start(BANDMAP_MAX_REFRESH_TIME);
Expand Down Expand Up @@ -191,7 +212,9 @@ void BandmapWidget::updateStations()

clearAllCallsignFromScene();

spotAging();
if (!isNonVfo) {
spotAging();
}

// do not show bandmap for submm bands
if ( rx_freq > 250000.0 || currentBand.start >= 300000.0 )
Expand Down Expand Up @@ -251,6 +274,10 @@ void BandmapWidget::updateStations()

pendingSpots = 0;
lastStationUpdate = QDateTime::currentMSecsSinceEpoch();
if (!isNonVfo) {
// signal to the non-vfo bandmaps that the spots should be redrawn
emit spotsUpdated();
}
}

void BandmapWidget::determineStepDigits(double &step, int &digits) const
Expand Down Expand Up @@ -378,9 +405,7 @@ void BandmapWidget::drawTXRXMarks(double step)
&& tx_freq != rx_freq )
{
drawFreqMark(tx_freq, step, QColor(255, 0, 0), &txMark);
}
else
{
} else {
clearFreqMark(&txMark);
}
}
Expand Down Expand Up @@ -523,6 +548,10 @@ void BandmapWidget::setBand(const Band &newBand, bool savePrevBandZoom)
zoom = getSavedZoom(newBand);
zoomFreq = getSavedScrollFreq(newBand);
zoomWidgetYOffset = WIDGET_CENTER;
if (isNonVfo) {
qCDebug(runtime) << objectName() << "set band" << newBand.name;
settings.setValue(objectName(), newBand.name);
}
}

void BandmapWidget::saveCurrentZoom()
Expand Down Expand Up @@ -812,11 +841,14 @@ void BandmapWidget::showContextMenu(const QPoint &point)
for ( const Band &enabledBand : BandPlan::bandsList(false, true))
{
QAction* action = new QAction(enabledBand.name);
connect(action, &QAction::triggered, this, [this, enabledBand]()
{
connect(action, &QAction::triggered, this, [this, enabledBand]() {
setBand(enabledBand);
update();
});
if (enabledBand == currentBand) {
action->setCheckable(true);
action->setChecked(true);
}
bandsMenu.addAction(action);
}

Expand All @@ -831,11 +863,15 @@ void BandmapWidget::showContextMenu(const QPoint &point)
contextMenu.exec(ui->graphicsView->mapToGlobal(point));
}

void BandmapWidget::updateTunedFrequency(VFOID, double vfoFreq, double ritFreq, double xitFreq)
void BandmapWidget::updateTunedFrequency(VFOID vfo, double vfoFreq, double ritFreq, double xitFreq)
{
FCT_IDENTIFICATION;

qCDebug(function_parameters) << vfoFreq << ritFreq << xitFreq;
if (isNonVfo) {
updateTunedFrequencyNonVfo(vfo, vfoFreq, ritFreq, xitFreq);
return;
}

/* always show the bandmap for RIT Freq */
rx_freq = ritFreq;
Expand Down Expand Up @@ -872,6 +908,34 @@ void BandmapWidget::updateTunedFrequency(VFOID, double vfoFreq, double ritFreq,
updateNearestSpot();
}

void BandmapWidget::updateTunedFrequencyNonVfo(VFOID, double vfoFreq, double ritFreq, double xitFreq)
{
FCT_IDENTIFICATION;

qCDebug(function_parameters) << vfoFreq << ritFreq << xitFreq;

/* always show the bandmap for RIT Freq */
rx_freq = ritFreq;
tx_freq = xitFreq;

if (rx_freq >= currentBand.start && rx_freq <= currentBand.end) {
// bandmap is showing the tuned frequency, so show the marker
double step;
int digits;

determineStepDigits(step, digits);

/************************/
/* Draw TX and RX Marks */
/************************/
drawTXRXMarks(step);
scrollToFreq(rx_freq);
} else {
clearFreqMark(&txMark);
clearFreqMark(&rxMark);
}
}

void BandmapWidget::updateMode(VFOID, const QString &, const QString &mode,
const QString &subMode, qint32 width)
{
Expand Down Expand Up @@ -986,13 +1050,10 @@ void BandmapWidget::scrollToFreq(double freq)
if ( freqScenePos < sliderSceneMin )
{
anim->setEndValue(sliderSceneMin - (sliderSceneMin - freqScenePos) - 40);
}
else if ( freqScenePos > sliderSceneMax - 20 ) //asymetric becuase possible slider below
} else if (freqScenePos > sliderSceneMax - 20) //asymetric becuase possible slider below
{
anim->setEndValue(sliderSceneMin + (freqScenePos - sliderSceneMax) + 60);
}
else
{
} else {
anim->setEndValue(ui->scrollArea->verticalScrollBar()->value());
}
}
Expand Down Expand Up @@ -1062,6 +1123,16 @@ void BandmapWidget::centerRXActionChecked(bool state)
scrollToFreq(rx_freq);
}

void BandmapWidget::clickNewBandmapWindow()
{
FCT_IDENTIFICATION;
emit requestNewNonVfoBandmapWindow();
}
Band *BandmapWidget::getBand()
{
return &currentBand;
}

void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *evt)
{
FCT_IDENTIFICATION;
Expand Down
12 changes: 9 additions & 3 deletions ui/BandmapWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class BandmapWidget : public QWidget
Q_OBJECT

public:
explicit BandmapWidget(QWidget *parent = nullptr);
explicit BandmapWidget(QWidget *parent = nullptr, QString nonVfoWidgetId = nullptr);
~BandmapWidget();

enum BandmapZoom {
Expand All @@ -54,6 +54,7 @@ class BandmapWidget : public QWidget
ZOOM_10KHZ
};

Band *getBand();
public slots:
void update();
void updateTunedFrequency(VFOID, double, double, double);
Expand All @@ -71,15 +72,18 @@ public slots:
void recalculateDxccStatus();
void resetDupe();
void recalculateDupe();
void clickNewBandmapWindow();
void updateStations();

signals:
void tuneDx(DxSpot);
void nearestSpotFound(const DxSpot &);
void requestNewNonVfoBandmapWindow();
void spotsUpdated();

private:
void removeDuplicates(DxSpot &spot);
void spotAging();
void updateStations();
void determineStepDigits(double &steps, int &digits) const;
void clearAllCallsignFromScene();
void clearFreqMark(QGraphicsPolygonItem **);
Expand All @@ -99,6 +103,7 @@ public slots:
void saveCurrentScrollFreq();
double getSavedScrollFreq(Band);
double visibleCentreFreq() const;
void updateTunedFrequencyNonVfo(VFOID, double, double, double);

private slots:
void centerRXActionChecked(bool);
Expand All @@ -115,7 +120,6 @@ private slots:
Band currentBand;
BandmapZoom zoom;
GraphicsScene* bandmapScene;
QMap<double, DxSpot> spots;
QTimer *update_timer;
QList<QGraphicsLineItem *> lineItemList;
QList<QGraphicsTextItem *> textItemList;
Expand All @@ -138,6 +142,8 @@ private slots:
};
LastTuneDx lastTunedDX;
DxSpot lastNearestSpot;
bool isNonVfo;
static QMap<double, DxSpot> spots;
};

Q_DECLARE_METATYPE(BandmapWidget::BandmapZoom)
Expand Down
Loading
Loading