1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2025-05-24 11:12:27 -04:00

Optmize redrawing of charts in Star Tracker

This commit is contained in:
Jon Beniston 2023-08-26 14:41:57 +01:00
parent 0e1f2f43ce
commit fd68709985
3 changed files with 33 additions and 57 deletions

View File

@ -108,9 +108,7 @@ bool StarTrackerGUI::handleMessage(const Message& message)
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings()); m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
} }
blockApplySettings(true);
displaySettings(); displaySettings();
blockApplySettings(false);
return true; return true;
} }
@ -118,8 +116,10 @@ bool StarTrackerGUI::handleMessage(const Message& message)
{ {
StarTrackerReport::MsgReportAzAl& azAl = (StarTrackerReport::MsgReportAzAl&) message; StarTrackerReport::MsgReportAzAl& azAl = (StarTrackerReport::MsgReportAzAl&) message;
blockApplySettings(true); blockApplySettings(true);
blockPlotChart();
ui->azimuth->setValue(azAl.getAzimuth()); ui->azimuth->setValue(azAl.getAzimuth());
ui->elevation->setValue(azAl.getElevation()); ui->elevation->setValue(azAl.getElevation());
unblockPlotChartAndPlot();
blockApplySettings(false); blockApplySettings(false);
return true; return true;
} }
@ -131,8 +131,10 @@ bool StarTrackerGUI::handleMessage(const Message& message)
{ {
m_settings.m_ra = Units::decimalHoursToHoursMinutesAndSeconds(raDec.getRA()); m_settings.m_ra = Units::decimalHoursToHoursMinutesAndSeconds(raDec.getRA());
m_settings.m_dec = Units::decimalDegreesToDegreeMinutesAndSeconds(raDec.getDec()); m_settings.m_dec = Units::decimalDegreesToDegreeMinutesAndSeconds(raDec.getDec());
blockPlotChart();
ui->rightAscension->setText(m_settings.m_ra); ui->rightAscension->setText(m_settings.m_ra);
ui->declination->setText(m_settings.m_dec); ui->declination->setText(m_settings.m_dec);
unblockPlotChartAndPlot();
} }
else if (target == "sun") else if (target == "sun")
{ {
@ -151,8 +153,10 @@ bool StarTrackerGUI::handleMessage(const Message& message)
{ {
StarTrackerReport::MsgReportGalactic& galactic = (StarTrackerReport::MsgReportGalactic&) message; StarTrackerReport::MsgReportGalactic& galactic = (StarTrackerReport::MsgReportGalactic&) message;
blockApplySettings(true); blockApplySettings(true);
blockPlotChart();
ui->galacticLongitude->setValue(galactic.getL()); ui->galacticLongitude->setValue(galactic.getL());
ui->galacticLatitude->setValue(galactic.getB()); ui->galacticLatitude->setValue(galactic.getB());
unblockPlotChartAndPlot();
blockApplySettings(false); blockApplySettings(false);
return true; return true;
} }
@ -166,8 +170,10 @@ bool StarTrackerGUI::handleMessage(const Message& message)
QDateTime dt = QDateTime::fromString(*swgSettings->getDateTime(), Qt::ISODateWithMs); QDateTime dt = QDateTime::fromString(*swgSettings->getDateTime(), Qt::ISODateWithMs);
ui->dateTime->setDateTime(dt); ui->dateTime->setDateTime(dt);
ui->target->setCurrentText("Custom Az/El"); ui->target->setCurrentText("Custom Az/El");
blockPlotChart();
ui->azimuth->setValue(swgSettings->getAzimuth()); ui->azimuth->setValue(swgSettings->getAzimuth());
ui->elevation->setValue(swgSettings->getElevation()); ui->elevation->setValue(swgSettings->getElevation());
unblockPlotChartAndPlot();
} }
return true; return true;
} }
@ -304,6 +310,7 @@ StarTrackerGUI::StarTrackerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet,
m_pluginAPI(pluginAPI), m_pluginAPI(pluginAPI),
m_featureUISet(featureUISet), m_featureUISet(featureUISet),
m_doApplySettings(true), m_doApplySettings(true),
m_doPlotChart(true),
m_lastFeatureState(0), m_lastFeatureState(0),
m_azElLineChart(nullptr), m_azElLineChart(nullptr),
m_azElPolarChart(nullptr), m_azElPolarChart(nullptr),
@ -399,6 +406,7 @@ StarTrackerGUI::StarTrackerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet,
ui->dateTime->setDateTime(QDateTime::currentDateTime()); ui->dateTime->setDateTime(QDateTime::currentDateTime());
displaySettings(); displaySettings();
applySettings(true); applySettings(true);
disconnect(ui->azimuth, SIGNAL(valueChanged(double)), this, SLOT(on_azimuth_valueChanged(double)));
makeUIConnections(); makeUIConnections();
// Populate subchart menu // Populate subchart menu
@ -471,12 +479,24 @@ void StarTrackerGUI::blockApplySettings(bool block)
m_doApplySettings = !block; m_doApplySettings = !block;
} }
void StarTrackerGUI::blockPlotChart()
{
m_doPlotChart = false;
}
void StarTrackerGUI::unblockPlotChartAndPlot()
{
m_doPlotChart = true;
plotChart();
}
void StarTrackerGUI::displaySettings() void StarTrackerGUI::displaySettings()
{ {
setTitleColor(m_settings.m_rgbColor); setTitleColor(m_settings.m_rgbColor);
setWindowTitle(m_settings.m_title); setWindowTitle(m_settings.m_title);
setTitle(m_settings.m_title); setTitle(m_settings.m_title);
blockApplySettings(true); blockApplySettings(true);
blockPlotChart();
ui->darkTheme->setChecked(m_settings.m_chartsDarkTheme); ui->darkTheme->setChecked(m_settings.m_chartsDarkTheme);
if (m_solarFluxChart) { if (m_solarFluxChart) {
@ -536,7 +556,7 @@ void StarTrackerGUI::displaySettings()
ui->beamwidth->setValue(m_settings.m_beamwidth); ui->beamwidth->setValue(m_settings.m_beamwidth);
updateForTarget(); updateForTarget();
getRollupContents()->restoreState(m_rollupState); getRollupContents()->restoreState(m_rollupState);
plotChart(); unblockPlotChartAndPlot();
blockApplySettings(false); blockApplySettings(false);
} }
@ -923,6 +943,9 @@ void StarTrackerGUI::on_dateTime_dateTimeChanged(const QDateTime &datetime)
void StarTrackerGUI::plotChart() void StarTrackerGUI::plotChart()
{ {
if (!m_doPlotChart) {
return;
}
if (ui->chartSelect->currentIndex() == 0) if (ui->chartSelect->currentIndex() == 0)
{ {
if (ui->chartSubSelect->currentIndex() == 0) { if (ui->chartSubSelect->currentIndex() == 0) {
@ -1647,32 +1670,8 @@ void StarTrackerGUI::plotElevationLineChart()
maxElevation = aa.alt; maxElevation = aa.alt;
} }
// Adjust for refraction // Skip adjusting for refraction, as it's too slow to calculate using Astronomy::refractionPAL
if (m_settings.m_refraction == "Positional Astronomy Library") // in this loop, and doesn't typically make a visible difference in the chart
{
aa.alt += Astronomy::refractionPAL(
aa.alt,
m_settings.m_pressure,
m_settings.m_temperature,
m_settings.m_humidity,
m_settings.m_frequency,
m_settings.m_latitude,
m_settings.m_heightAboveSeaLevel,
m_settings.m_temperatureLapseRate
);
if (aa.alt > 90.0) {
aa.alt = 90.0f;
}
}
else if (m_settings.m_refraction == "Saemundsson")
{
aa.alt += Astronomy::refractionSaemundsson(aa.alt, m_settings.m_pressure, m_settings.m_temperature);
if (aa.alt > 90.0) {
aa.alt = 90.0f;
}
}
if (step == 0) { if (step == 0) {
prevAz = aa.az; prevAz = aa.az;
@ -1857,32 +1856,8 @@ void StarTrackerGUI::plotElevationPolarChart()
maxElevation = aa.alt; maxElevation = aa.alt;
} }
// Adjust for refraction // Skip adjusting for refraction, as it's too slow to calculate using Astronomy::refractionPAL
if (m_settings.m_refraction == "Positional Astronomy Library") // in this loop, and doesn't typically make a visible difference in the chart
{
aa.alt += Astronomy::refractionPAL(
aa.alt,
m_settings.m_pressure,
m_settings.m_temperature,
m_settings.m_humidity,
m_settings.m_frequency,
m_settings.m_latitude,
m_settings.m_heightAboveSeaLevel,
m_settings.m_temperatureLapseRate
);
if (aa.alt > 90.0) {
aa.alt = 90.0f;
}
}
else if (m_settings.m_refraction == "Saemundsson")
{
aa.alt += Astronomy::refractionSaemundsson(aa.alt, m_settings.m_pressure, m_settings.m_temperature);
if (aa.alt > 90.0) {
aa.alt = 90.0f;
}
}
if (idx == 0) { if (idx == 0) {
prevAlt = aa.alt; prevAlt = aa.alt;

View File

@ -81,6 +81,7 @@ private:
QList<QString> m_settingsKeys; QList<QString> m_settingsKeys;
RollupState m_rollupState; RollupState m_rollupState;
bool m_doApplySettings; bool m_doApplySettings;
bool m_doPlotChart;
StarTracker* m_starTracker; StarTracker* m_starTracker;
MessageQueue m_inputMessageQueue; MessageQueue m_inputMessageQueue;
@ -135,6 +136,8 @@ private:
virtual ~StarTrackerGUI(); virtual ~StarTrackerGUI();
void blockApplySettings(bool block); void blockApplySettings(bool block);
void blockPlotChart();
void unblockPlotChartAndPlot();
void applySettings(bool force = false); void applySettings(bool force = false);
void displaySettings(); void displaySettings();
void updateForTarget(); void updateForTarget();

View File

@ -519,8 +519,6 @@ void StarTrackerWorker::update()
else else
qDebug() << "StarTrackerWorker::update - Failed to parse feature name " << m_settings.m_target; qDebug() << "StarTrackerWorker::update - Failed to parse feature name " << m_settings.m_target;
} }
else
qDebug() << "TARGET IS NOT SAT TRACKER!! " << m_settings.m_target;
if (m_settings.m_target == "Sun") if (m_settings.m_target == "Sun")
{ {