mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-12-23 01:55:48 -05:00
Star Tracker feature: Make settings assignments atomic. Part of #1329
This commit is contained in:
parent
7906ece977
commit
c61bc00260
@ -121,7 +121,7 @@ void StarTracker::start()
|
||||
m_thread->start();
|
||||
m_state = StRunning;
|
||||
|
||||
m_worker->getInputMessageQueue()->push(StarTrackerWorker::MsgConfigureStarTrackerWorker::create(m_settings, true));
|
||||
m_worker->getInputMessageQueue()->push(StarTrackerWorker::MsgConfigureStarTrackerWorker::create(m_settings, QList<QString>(), true));
|
||||
m_worker->getInputMessageQueue()->push(MsgSetSolarFlux::create(m_solarFlux));
|
||||
}
|
||||
|
||||
@ -144,7 +144,7 @@ bool StarTracker::handleMessage(const Message& cmd)
|
||||
{
|
||||
MsgConfigureStarTracker& cfg = (MsgConfigureStarTracker&) cmd;
|
||||
qDebug() << "StarTracker::handleMessage: MsgConfigureStarTracker";
|
||||
applySettings(cfg.getSettings(), cfg.getForce());
|
||||
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -201,123 +201,24 @@ bool StarTracker::deserialize(const QByteArray& data)
|
||||
{
|
||||
if (m_settings.deserialize(data))
|
||||
{
|
||||
MsgConfigureStarTracker *msg = MsgConfigureStarTracker::create(m_settings, true);
|
||||
MsgConfigureStarTracker *msg = MsgConfigureStarTracker::create(m_settings, QList<QString>(), true);
|
||||
m_inputMessageQueue.push(msg);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_settings.resetToDefaults();
|
||||
MsgConfigureStarTracker *msg = MsgConfigureStarTracker::create(m_settings, true);
|
||||
MsgConfigureStarTracker *msg = MsgConfigureStarTracker::create(m_settings, QList<QString>(), true);
|
||||
m_inputMessageQueue.push(msg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void StarTracker::applySettings(const StarTrackerSettings& settings, bool force)
|
||||
void StarTracker::applySettings(const StarTrackerSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||
{
|
||||
qDebug() << "StarTracker::applySettings:"
|
||||
<< " m_target: " << settings.m_target
|
||||
<< " m_ra: " << settings.m_ra
|
||||
<< " m_dec: " << settings.m_dec
|
||||
<< " m_az: " << settings.m_az
|
||||
<< " m_el: " << settings.m_el
|
||||
<< " m_l: " << settings.m_l
|
||||
<< " m_b: " << settings.m_b
|
||||
<< " m_azOffset: " << settings.m_azOffset
|
||||
<< " m_elOffset: " << settings.m_elOffset
|
||||
<< " m_latitude: " << settings.m_latitude
|
||||
<< " m_longitude: " << settings.m_longitude
|
||||
<< " m_serverPort: " << settings.m_serverPort
|
||||
<< " m_enableServer: " << settings.m_enableServer
|
||||
<< " m_title: " << settings.m_title
|
||||
<< " m_rgbColor: " << settings.m_rgbColor
|
||||
<< " m_useReverseAPI: " << settings.m_useReverseAPI
|
||||
<< " m_reverseAPIAddress: " << settings.m_reverseAPIAddress
|
||||
<< " m_reverseAPIPort: " << settings.m_reverseAPIPort
|
||||
<< " m_reverseAPIFeatureSetIndex: " << settings.m_reverseAPIFeatureSetIndex
|
||||
<< " m_reverseAPIFeatureIndex: " << settings.m_reverseAPIFeatureIndex
|
||||
<< " force: " << force;
|
||||
qDebug() << "StarTracker::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force;
|
||||
|
||||
QList<QString> reverseAPIKeys;
|
||||
|
||||
if ((m_settings.m_target != settings.m_target) || force) {
|
||||
reverseAPIKeys.append("target");
|
||||
}
|
||||
if ((m_settings.m_ra != settings.m_ra) || force) {
|
||||
reverseAPIKeys.append("ra");
|
||||
}
|
||||
if ((m_settings.m_dec != settings.m_dec) || force) {
|
||||
reverseAPIKeys.append("dec");
|
||||
}
|
||||
if ((m_settings.m_latitude != settings.m_latitude) || force) {
|
||||
reverseAPIKeys.append("latitude");
|
||||
}
|
||||
if ((m_settings.m_longitude != settings.m_longitude) || force) {
|
||||
reverseAPIKeys.append("longitude");
|
||||
}
|
||||
if ((m_settings.m_dateTime != settings.m_dateTime) || force) {
|
||||
reverseAPIKeys.append("dateTime");
|
||||
}
|
||||
if ((m_settings.m_refraction != settings.m_refraction) || force) {
|
||||
reverseAPIKeys.append("refraction");
|
||||
}
|
||||
if ((m_settings.m_pressure != settings.m_pressure) || force) {
|
||||
reverseAPIKeys.append("pressure");
|
||||
}
|
||||
if ((m_settings.m_temperature != settings.m_temperature) || force) {
|
||||
reverseAPIKeys.append("temperature");
|
||||
}
|
||||
if ((m_settings.m_humidity != settings.m_humidity) || force) {
|
||||
reverseAPIKeys.append("humidity");
|
||||
}
|
||||
if ((m_settings.m_heightAboveSeaLevel != settings.m_heightAboveSeaLevel) || force) {
|
||||
reverseAPIKeys.append("heightAboveSeaLevel");
|
||||
}
|
||||
if ((m_settings.m_temperatureLapseRate != settings.m_temperatureLapseRate) || force) {
|
||||
reverseAPIKeys.append("temperatureLapseRate");
|
||||
}
|
||||
if ((m_settings.m_frequency != settings.m_frequency) || force) {
|
||||
reverseAPIKeys.append("frequency");
|
||||
}
|
||||
if ((m_settings.m_serverPort != settings.m_serverPort) || force) {
|
||||
reverseAPIKeys.append("stellariumPort");
|
||||
}
|
||||
if ((m_settings.m_enableServer != settings.m_enableServer) || force) {
|
||||
reverseAPIKeys.append("stellariumServerEnabled");
|
||||
}
|
||||
if ((m_settings.m_updatePeriod != settings.m_updatePeriod) || force) {
|
||||
reverseAPIKeys.append("updatePeriod");
|
||||
}
|
||||
if ((m_settings.m_jnow != settings.m_jnow) || force) {
|
||||
reverseAPIKeys.append("epoch");
|
||||
}
|
||||
if ((m_settings.m_title != settings.m_title) || force) {
|
||||
reverseAPIKeys.append("title");
|
||||
}
|
||||
if ((m_settings.m_rgbColor != settings.m_rgbColor) || force) {
|
||||
reverseAPIKeys.append("rgbColor");
|
||||
}
|
||||
if ((m_settings.m_az != settings.m_az) || force) {
|
||||
reverseAPIKeys.append("azimuth");
|
||||
}
|
||||
if ((m_settings.m_el != settings.m_el) || force) {
|
||||
reverseAPIKeys.append("elevation");
|
||||
}
|
||||
if ((m_settings.m_l != settings.m_l) || force) {
|
||||
reverseAPIKeys.append("l");
|
||||
}
|
||||
if ((m_settings.m_b != settings.m_b) || force) {
|
||||
reverseAPIKeys.append("b");
|
||||
}
|
||||
if ((m_settings.m_azOffset != settings.m_azOffset) || force) {
|
||||
reverseAPIKeys.append("azimuthOffset");
|
||||
}
|
||||
if ((m_settings.m_elOffset != settings.m_elOffset) || force) {
|
||||
reverseAPIKeys.append("elevationOffset");
|
||||
}
|
||||
|
||||
if ((m_settings.m_owmAPIKey != settings.m_owmAPIKey) || force)
|
||||
if (settingsKeys.contains("owmAPIKey") || force)
|
||||
{
|
||||
if (m_weather)
|
||||
{
|
||||
@ -334,10 +235,10 @@ void StarTracker::applySettings(const StarTrackerSettings& settings, bool force)
|
||||
}
|
||||
}
|
||||
|
||||
if ( (m_settings.m_owmAPIKey != settings.m_owmAPIKey)
|
||||
|| (m_settings.m_latitude != settings.m_latitude)
|
||||
|| (m_settings.m_longitude != settings.m_longitude)
|
||||
|| (m_settings.m_weatherUpdatePeriod != settings.m_weatherUpdatePeriod)
|
||||
if (settingsKeys.contains("owmAPIKey")
|
||||
|| settingsKeys.contains("latitude")
|
||||
|| settingsKeys.contains("longitude")
|
||||
|| settingsKeys.contains("weatherUpdatePeriod")
|
||||
|| force)
|
||||
{
|
||||
if (m_weather) {
|
||||
@ -346,20 +247,20 @@ void StarTracker::applySettings(const StarTrackerSettings& settings, bool force)
|
||||
}
|
||||
|
||||
StarTrackerWorker::MsgConfigureStarTrackerWorker *msg = StarTrackerWorker::MsgConfigureStarTrackerWorker::create(
|
||||
settings, force
|
||||
settings, settingsKeys, force
|
||||
);
|
||||
if (m_worker) {
|
||||
m_worker->getInputMessageQueue()->push(msg);
|
||||
}
|
||||
|
||||
if (settings.m_useReverseAPI)
|
||||
if (settingsKeys.contains("useReverseAPI"))
|
||||
{
|
||||
bool fullUpdate = ((m_settings.m_useReverseAPI != settings.m_useReverseAPI) && settings.m_useReverseAPI) ||
|
||||
(m_settings.m_reverseAPIAddress != settings.m_reverseAPIAddress) ||
|
||||
(m_settings.m_reverseAPIPort != settings.m_reverseAPIPort) ||
|
||||
(m_settings.m_reverseAPIFeatureSetIndex != settings.m_reverseAPIFeatureSetIndex) ||
|
||||
(m_settings.m_reverseAPIFeatureIndex != settings.m_reverseAPIFeatureIndex);
|
||||
webapiReverseSendSettings(reverseAPIKeys, settings, fullUpdate || force);
|
||||
bool fullUpdate = (settingsKeys.contains("useReverseAPI") && settings.m_useReverseAPI) ||
|
||||
settingsKeys.contains("reverseAPIAddress") ||
|
||||
settingsKeys.contains("reverseAPIPort") ||
|
||||
settingsKeys.contains("reverseAPIFeatureSetIndex") ||
|
||||
settingsKeys.contains("m_reverseAPIFeatureIndex");
|
||||
webapiReverseSendSettings(settingsKeys, settings, fullUpdate || force);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
@ -397,13 +298,13 @@ int StarTracker::webapiSettingsPutPatch(
|
||||
StarTrackerSettings settings = m_settings;
|
||||
webapiUpdateFeatureSettings(settings, featureSettingsKeys, response);
|
||||
|
||||
MsgConfigureStarTracker *msg = MsgConfigureStarTracker::create(settings, force);
|
||||
MsgConfigureStarTracker *msg = MsgConfigureStarTracker::create(settings, featureSettingsKeys, force);
|
||||
m_inputMessageQueue.push(msg);
|
||||
|
||||
qDebug("StarTracker::webapiSettingsPutPatch: forward to GUI: %p", m_guiMessageQueue);
|
||||
if (m_guiMessageQueue) // forward to GUI if any
|
||||
{
|
||||
MsgConfigureStarTracker *msgToGUI = MsgConfigureStarTracker::create(settings, force);
|
||||
MsgConfigureStarTracker *msgToGUI = MsgConfigureStarTracker::create(settings, featureSettingsKeys, force);
|
||||
m_guiMessageQueue->push(msgToGUI);
|
||||
}
|
||||
|
||||
@ -616,7 +517,7 @@ void StarTracker::webapiUpdateFeatureSettings(
|
||||
}
|
||||
}
|
||||
|
||||
void StarTracker::webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const StarTrackerSettings& settings, bool force)
|
||||
void StarTracker::webapiReverseSendSettings(const QList<QString>& featureSettingsKeys, const StarTrackerSettings& settings, bool force)
|
||||
{
|
||||
SWGSDRangel::SWGFeatureSettings *swgFeatureSettings = new SWGSDRangel::SWGFeatureSettings();
|
||||
// swgFeatureSettings->setOriginatorFeatureIndex(getIndexInDeviceSet());
|
||||
@ -743,21 +644,32 @@ void StarTracker::networkManagerFinished(QNetworkReply *reply)
|
||||
|
||||
void StarTracker::weatherUpdated(float temperature, float pressure, float humidity)
|
||||
{
|
||||
if (!std::isnan(temperature)) {
|
||||
QList<QString> settingsKeys;
|
||||
|
||||
if (!std::isnan(temperature))
|
||||
{
|
||||
m_settings.m_temperature = temperature;
|
||||
settingsKeys.append("temperature");
|
||||
}
|
||||
if (!std::isnan(pressure)) {
|
||||
|
||||
if (!std::isnan(pressure))
|
||||
{
|
||||
m_settings.m_pressure = pressure;
|
||||
settingsKeys.append("pressure");
|
||||
}
|
||||
if (!std::isnan(humidity)) {
|
||||
|
||||
if (!std::isnan(humidity))
|
||||
{
|
||||
m_settings.m_humidity = humidity;
|
||||
settingsKeys.append("humidity");
|
||||
}
|
||||
|
||||
if (m_worker) {
|
||||
m_worker->getInputMessageQueue()->push(StarTrackerWorker::MsgConfigureStarTrackerWorker::create(m_settings, false));
|
||||
m_worker->getInputMessageQueue()->push(StarTrackerWorker::MsgConfigureStarTrackerWorker::create(m_settings, settingsKeys, false));
|
||||
}
|
||||
|
||||
if (m_guiMessageQueue) {
|
||||
m_guiMessageQueue->push(MsgConfigureStarTracker::create(m_settings, false));
|
||||
m_guiMessageQueue->push(MsgConfigureStarTracker::create(m_settings, settingsKeys, false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,19 +48,22 @@ public:
|
||||
|
||||
public:
|
||||
const StarTrackerSettings& getSettings() const { return m_settings; }
|
||||
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigureStarTracker* create(const StarTrackerSettings& settings, bool force) {
|
||||
return new MsgConfigureStarTracker(settings, force);
|
||||
static MsgConfigureStarTracker* create(const StarTrackerSettings& settings, const QList<QString>& settingsKeys, bool force) {
|
||||
return new MsgConfigureStarTracker(settings, settingsKeys, force);
|
||||
}
|
||||
|
||||
private:
|
||||
StarTrackerSettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigureStarTracker(const StarTrackerSettings& settings, bool force) :
|
||||
MsgConfigureStarTracker(const StarTrackerSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_settingsKeys(settingsKeys),
|
||||
m_force(force)
|
||||
{ }
|
||||
};
|
||||
@ -170,8 +173,8 @@ private:
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
void applySettings(const StarTrackerSettings& settings, bool force = false);
|
||||
void webapiReverseSendSettings(QList<QString>& featureSettingsKeys, const StarTrackerSettings& settings, bool force);
|
||||
void applySettings(const StarTrackerSettings& settings, const QList<QString>& settingsKeys, bool force = false);
|
||||
void webapiReverseSendSettings(const QList<QString>& featureSettingsKeys, const StarTrackerSettings& settings, bool force);
|
||||
void webapiFormatFeatureReport(SWGSDRangel::SWGFeatureReport& response);
|
||||
double applyBeam(const FITS *fits, double beamwidth, double ra, double dec, int& imgX, int& imgY) const;
|
||||
void scanAvailableChannels();
|
||||
|
@ -97,7 +97,13 @@ bool StarTrackerGUI::handleMessage(const Message& message)
|
||||
{
|
||||
qDebug("StarTrackerGUI::handleMessage: StarTracker::MsgConfigureStarTracker");
|
||||
const StarTracker::MsgConfigureStarTracker& cfg = (StarTracker::MsgConfigureStarTracker&) message;
|
||||
m_settings = cfg.getSettings();
|
||||
|
||||
if (cfg.getForce()) {
|
||||
m_settings = cfg.getSettings();
|
||||
} else {
|
||||
m_settings.applySettings(cfg.getSettingsKeys(), cfg.getSettings());
|
||||
}
|
||||
|
||||
blockApplySettings(true);
|
||||
displaySettings();
|
||||
blockApplySettings(false);
|
||||
@ -338,8 +344,9 @@ StarTrackerGUI::StarTrackerGUI(PluginAPI* pluginAPI, FeatureUISet *featureUISet,
|
||||
connect(&m_chart, SIGNAL(plotAreaChanged(QRectF)), this, SLOT(plotAreaChanged(QRectF)));
|
||||
|
||||
// Use My Position from preferences, if none set
|
||||
if ((m_settings.m_latitude == 0.0) && (m_settings.m_longitude == 0.0))
|
||||
if ((m_settings.m_latitude == 0.0) && (m_settings.m_longitude == 0.0)) {
|
||||
on_useMyPosition_clicked();
|
||||
}
|
||||
|
||||
/*
|
||||
printf("saemundsson=[");
|
||||
@ -392,6 +399,7 @@ StarTrackerGUI::~StarTrackerGUI()
|
||||
void StarTrackerGUI::setWorkspaceIndex(int index)
|
||||
{
|
||||
m_settings.m_workspaceIndex = index;
|
||||
m_settingsKeys.append("workspaceIndex");
|
||||
m_feature->setWorkspaceIndex(index);
|
||||
}
|
||||
|
||||
@ -407,9 +415,11 @@ void StarTrackerGUI::displaySettings()
|
||||
setTitle(m_settings.m_title);
|
||||
blockApplySettings(true);
|
||||
ui->darkTheme->setChecked(m_settings.m_chartsDarkTheme);
|
||||
|
||||
if (m_solarFluxChart) {
|
||||
m_solarFluxChart->setTheme(m_settings.m_chartsDarkTheme ? QChart::ChartThemeDark : QChart::ChartThemeLight);
|
||||
}
|
||||
|
||||
m_chart.setTheme(m_settings.m_chartsDarkTheme ? QChart::ChartThemeDark : QChart::ChartThemeLight);
|
||||
ui->drawSun->setChecked(m_settings.m_drawSunOnSkyTempChart);
|
||||
ui->drawMoon->setChecked(m_settings.m_drawMoonOnSkyTempChart);
|
||||
@ -423,6 +433,7 @@ void StarTrackerGUI::displaySettings()
|
||||
ui->galacticLongitude->setUnits((DMSSpinBox::DisplayUnits)m_settings.m_azElUnits);
|
||||
ui->azimuthOffset->setValue(m_settings.m_azOffset);
|
||||
ui->elevationOffset->setValue(m_settings.m_elOffset);
|
||||
|
||||
if (m_settings.m_target == "Custom RA/Dec")
|
||||
{
|
||||
ui->rightAscension->setText(m_settings.m_ra);
|
||||
@ -433,11 +444,11 @@ void StarTrackerGUI::displaySettings()
|
||||
ui->azimuth->setValue(m_settings.m_az);
|
||||
ui->elevation->setValue(m_settings.m_el);
|
||||
}
|
||||
else if ( (m_settings.m_target == "Custom l/b")
|
||||
|| (m_settings.m_target == "S7")
|
||||
|| (m_settings.m_target == "S8")
|
||||
|| (m_settings.m_target == "S9")
|
||||
)
|
||||
else if ((m_settings.m_target == "Custom l/b")
|
||||
|| (m_settings.m_target == "S7")
|
||||
|| (m_settings.m_target == "S8")
|
||||
|| (m_settings.m_target == "S9")
|
||||
)
|
||||
{
|
||||
ui->galacticLatitude->setValue(m_settings.m_b);
|
||||
ui->galacticLongitude->setValue(m_settings.m_l);
|
||||
@ -453,8 +464,11 @@ void StarTrackerGUI::displaySettings()
|
||||
ui->dateTime->setVisible(true);
|
||||
ui->dateTimeSelect->setCurrentIndex(1);
|
||||
}
|
||||
if ((m_settings.m_solarFluxData != StarTrackerSettings::DRAO_2800) && !m_solarFluxesValid)
|
||||
|
||||
if ((m_settings.m_solarFluxData != StarTrackerSettings::DRAO_2800) && !m_solarFluxesValid) {
|
||||
autoUpdateSolarFlux();
|
||||
}
|
||||
|
||||
ui->frequency->setValue(m_settings.m_frequency/1000000.0);
|
||||
ui->beamwidth->setValue(m_settings.m_beamwidth);
|
||||
updateForTarget();
|
||||
@ -489,6 +503,14 @@ void StarTrackerGUI::onMenuDialogCalled(const QPoint &p)
|
||||
setTitle(m_settings.m_title);
|
||||
setTitleColor(m_settings.m_rgbColor);
|
||||
|
||||
m_settingsKeys.append("title");
|
||||
m_settingsKeys.append("rgbColor");
|
||||
m_settingsKeys.append("useReverseAPI");
|
||||
m_settingsKeys.append("reverseAPIAddress");
|
||||
m_settingsKeys.append("reverseAPIPort");
|
||||
m_settingsKeys.append("reverseAPIFeatureSetIndex");
|
||||
m_settingsKeys.append("reverseAPIFeatureIndex");
|
||||
|
||||
applySettings();
|
||||
}
|
||||
|
||||
@ -507,6 +529,7 @@ void StarTrackerGUI::on_startStop_toggled(bool checked)
|
||||
void StarTrackerGUI::on_latitude_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_latitude = value;
|
||||
m_settingsKeys.append("latitude");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -514,6 +537,7 @@ void StarTrackerGUI::on_latitude_valueChanged(double value)
|
||||
void StarTrackerGUI::on_longitude_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_longitude = value;
|
||||
m_settingsKeys.append("longitude");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -521,6 +545,7 @@ void StarTrackerGUI::on_longitude_valueChanged(double value)
|
||||
void StarTrackerGUI::on_rightAscension_editingFinished()
|
||||
{
|
||||
m_settings.m_ra = ui->rightAscension->text();
|
||||
m_settingsKeys.append("ra");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -528,6 +553,7 @@ void StarTrackerGUI::on_rightAscension_editingFinished()
|
||||
void StarTrackerGUI::on_declination_editingFinished()
|
||||
{
|
||||
m_settings.m_dec = ui->declination->text();
|
||||
m_settingsKeys.append("dec");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -535,6 +561,7 @@ void StarTrackerGUI::on_declination_editingFinished()
|
||||
void StarTrackerGUI::on_azimuth_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_az = value;
|
||||
m_settingsKeys.append("az");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -542,6 +569,7 @@ void StarTrackerGUI::on_azimuth_valueChanged(double value)
|
||||
void StarTrackerGUI::on_elevation_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_el = value;
|
||||
m_settingsKeys.append("el");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -549,6 +577,7 @@ void StarTrackerGUI::on_elevation_valueChanged(double value)
|
||||
void StarTrackerGUI::on_azimuthOffset_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_azOffset = value;
|
||||
m_settingsKeys.append("azOffset");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -556,6 +585,7 @@ void StarTrackerGUI::on_azimuthOffset_valueChanged(double value)
|
||||
void StarTrackerGUI::on_elevationOffset_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_elOffset = value;
|
||||
m_settingsKeys.append("elOffset");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -563,6 +593,7 @@ void StarTrackerGUI::on_elevationOffset_valueChanged(double value)
|
||||
void StarTrackerGUI::on_galacticLatitude_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_b = value;
|
||||
m_settingsKeys.append("b");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -570,6 +601,7 @@ void StarTrackerGUI::on_galacticLatitude_valueChanged(double value)
|
||||
void StarTrackerGUI::on_galacticLongitude_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_l = value;
|
||||
m_settingsKeys.append("l");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -672,6 +704,7 @@ void StarTrackerGUI::updateForTarget()
|
||||
void StarTrackerGUI::on_target_currentTextChanged(const QString &text)
|
||||
{
|
||||
m_settings.m_target = text;
|
||||
m_settingsKeys.append("target");
|
||||
applySettings();
|
||||
updateForTarget();
|
||||
plotChart();
|
||||
@ -681,13 +714,13 @@ void StarTrackerGUI::updateLST()
|
||||
{
|
||||
QDateTime dt;
|
||||
|
||||
if (m_settings.m_dateTime.isEmpty())
|
||||
if (m_settings.m_dateTime.isEmpty()) {
|
||||
dt = QDateTime::currentDateTime();
|
||||
else
|
||||
} else {
|
||||
dt = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs);
|
||||
}
|
||||
|
||||
double lst = Astronomy::localSiderealTime(dt, m_settings.m_longitude);
|
||||
|
||||
ui->lst->setText(Units::decimalHoursToHoursMinutesAndSeconds(lst/15.0, 0));
|
||||
}
|
||||
|
||||
@ -734,14 +767,17 @@ void StarTrackerGUI::applySettings(bool force)
|
||||
{
|
||||
if (m_doApplySettings)
|
||||
{
|
||||
StarTracker::MsgConfigureStarTracker* message = StarTracker::MsgConfigureStarTracker::create(m_settings, force);
|
||||
StarTracker::MsgConfigureStarTracker* message = StarTracker::MsgConfigureStarTracker::create(m_settings, m_settingsKeys, force);
|
||||
m_starTracker->getInputMessageQueue()->push(message);
|
||||
}
|
||||
|
||||
m_settingsKeys.clear();
|
||||
}
|
||||
|
||||
void StarTrackerGUI::on_link_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_link = checked;
|
||||
m_settingsKeys.append("link");
|
||||
applySettings();
|
||||
}
|
||||
|
||||
@ -755,6 +791,7 @@ void StarTrackerGUI::on_useMyPosition_clicked(bool checked)
|
||||
ui->latitude->setValue(stationLatitude);
|
||||
ui->longitude->setValue(stationLongitude);
|
||||
m_settings.m_heightAboveSeaLevel = stationAltitude;
|
||||
m_settingsKeys.append("heightAboveSeaLevel");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -762,7 +799,8 @@ void StarTrackerGUI::on_useMyPosition_clicked(bool checked)
|
||||
// Show settings dialog
|
||||
void StarTrackerGUI::on_displaySettings_clicked()
|
||||
{
|
||||
StarTrackerSettingsDialog dialog(&m_settings);
|
||||
StarTrackerSettingsDialog dialog(&m_settings, m_settingsKeys);
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted)
|
||||
{
|
||||
applySettings();
|
||||
@ -771,8 +809,10 @@ void StarTrackerGUI::on_displaySettings_clicked()
|
||||
ui->galacticLatitude->setUnits((DMSSpinBox::DisplayUnits)m_settings.m_azElUnits);
|
||||
ui->galacticLongitude->setUnits((DMSSpinBox::DisplayUnits)m_settings.m_azElUnits);
|
||||
displaySolarFlux();
|
||||
if (ui->chartSelect->currentIndex() == 1)
|
||||
|
||||
if (ui->chartSelect->currentIndex() == 1) {
|
||||
plotChart();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -788,6 +828,8 @@ void StarTrackerGUI::on_dateTimeSelect_currentTextChanged(const QString &text)
|
||||
m_settings.m_dateTime = ui->dateTime->dateTime().toString(Qt::ISODateWithMs);
|
||||
ui->dateTime->setVisible(true);
|
||||
}
|
||||
|
||||
m_settingsKeys.append("dateTime");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -795,9 +837,11 @@ void StarTrackerGUI::on_dateTimeSelect_currentTextChanged(const QString &text)
|
||||
void StarTrackerGUI::on_dateTime_dateTimeChanged(const QDateTime &datetime)
|
||||
{
|
||||
(void) datetime;
|
||||
|
||||
if (ui->dateTimeSelect->currentIndex() == 1)
|
||||
{
|
||||
m_settings.m_dateTime = ui->dateTime->dateTime().toString(Qt::ISODateWithMs);
|
||||
m_settingsKeys.append("dateTime");
|
||||
applySettings();
|
||||
plotChart();
|
||||
}
|
||||
@ -839,22 +883,28 @@ void StarTrackerGUI::raDecChanged()
|
||||
void StarTrackerGUI::on_frequency_valueChanged(int value)
|
||||
{
|
||||
m_settings.m_frequency = value*1000000.0;
|
||||
m_settingsKeys.append("frequency");
|
||||
applySettings();
|
||||
|
||||
if (ui->chartSelect->currentIndex() != 0)
|
||||
{
|
||||
updateChartSubSelect();
|
||||
plotChart();
|
||||
}
|
||||
|
||||
displaySolarFlux();
|
||||
}
|
||||
|
||||
void StarTrackerGUI::on_beamwidth_valueChanged(double value)
|
||||
{
|
||||
m_settings.m_beamwidth = value;
|
||||
m_settingsKeys.append("beamwidth");
|
||||
applySettings();
|
||||
updateChartSubSelect();
|
||||
if (ui->chartSelect->currentIndex() == 2)
|
||||
|
||||
if (ui->chartSelect->currentIndex() == 2) {
|
||||
plotChart();
|
||||
}
|
||||
}
|
||||
|
||||
void StarTrackerGUI::plotSolarFluxChart()
|
||||
@ -1202,9 +1252,11 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
|
||||
// Plot drift scan path
|
||||
QList<QLineSeries*> lineSeries;
|
||||
if (m_settings.m_target == "Custom Az/El") {
|
||||
if (m_settings.m_target == "Custom Az/El")
|
||||
{
|
||||
lineSeries = createDriftScan(galactic);
|
||||
QPen pen(getSeriesColor(1), 2, Qt::SolidLine);
|
||||
|
||||
for (int i = 0; i < lineSeries.length(); i++) {
|
||||
lineSeries[i]->setPen(pen);
|
||||
}
|
||||
@ -1227,9 +1279,11 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
|
||||
// Get temperature
|
||||
int idx = ui->chartSubSelect->currentIndex();
|
||||
|
||||
if ((idx == 6) || (idx == 7))
|
||||
{
|
||||
double temp;
|
||||
|
||||
if (m_starTracker->calcSkyTemperature(m_settings.m_frequency, m_settings.m_beamwidth, ra, dec, temp))
|
||||
{
|
||||
series->setPointLabelsVisible(true);
|
||||
@ -1246,16 +1300,21 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
QImage *img = &m_images[idx];
|
||||
const FITS *fits = m_starTracker->getTempFITS(idx/2);
|
||||
double x;
|
||||
|
||||
if (ra <= 12.0) {
|
||||
x = (12.0 - ra) / 24.0;
|
||||
} else {
|
||||
x = (24 - ra + 12) / 24.0;
|
||||
}
|
||||
|
||||
int imgX = x * (img->width() - 1);
|
||||
|
||||
if (imgX >= img->width()) {
|
||||
imgX = img->width() - 1;
|
||||
}
|
||||
|
||||
int imgY = (90.0-dec)/180.0 * (img->height() - 1);
|
||||
|
||||
if (imgY >= img->height()) {
|
||||
imgY = img->height() - 1;
|
||||
}
|
||||
@ -1275,9 +1334,9 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
// Temperature from just one pixel, but need to make marker visbile
|
||||
markerSize = 5;
|
||||
}
|
||||
|
||||
series->setMarkerSize(markerSize);
|
||||
series->setColor(getSeriesColor(0));
|
||||
|
||||
m_chart.setTitle("");
|
||||
|
||||
// We want scatter (for the beam) to be on top of line, but same color even when other series
|
||||
@ -1295,12 +1354,14 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
sunSeries->setMarkerSize((int)std::max(std::round(0.53 * degPerPixel), 5.0));
|
||||
sunSeries->setColor(Qt::yellow);
|
||||
sunSeries->setBorderColor(Qt::yellow);
|
||||
|
||||
if (m_settings.m_target != "Sun") // Avoid labels on top of each other
|
||||
{
|
||||
sunSeries->setPointLabelsVisible(true);
|
||||
sunSeries->setPointLabelsColor(Qt::red);
|
||||
sunSeries->setPointLabelsFormat("Sun");
|
||||
}
|
||||
|
||||
m_chart.addSeries(sunSeries);
|
||||
}
|
||||
|
||||
@ -1314,12 +1375,14 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
moonSeries->setMarkerSize((int)std::max(std::round(0.53 * degPerPixel), 5.0));
|
||||
moonSeries->setColor(qRgb(150, 150, 150));
|
||||
moonSeries->setBorderColor(qRgb(150, 150, 150));
|
||||
|
||||
if (m_settings.m_target != "Moon") // Avoid labels on top of each other
|
||||
{
|
||||
moonSeries->setPointLabelsVisible(true);
|
||||
moonSeries->setPointLabelsColor(Qt::red);
|
||||
moonSeries->setPointLabelsFormat("Moon");
|
||||
}
|
||||
|
||||
m_chart.addSeries(moonSeries);
|
||||
}
|
||||
|
||||
@ -1329,6 +1392,7 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
{
|
||||
m_chart.addAxis(&m_skyTempGalacticLXAxis, Qt::AlignBottom);
|
||||
series->attachAxis(&m_skyTempGalacticLXAxis);
|
||||
|
||||
if (sunSeries) {
|
||||
sunSeries->attachAxis(&m_skyTempGalacticLXAxis);
|
||||
}
|
||||
@ -1339,6 +1403,7 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
m_skyTempYAxis.setTitleText(QString("Galactic latitude (%1)").arg(QChar(0xb0)));
|
||||
m_chart.addAxis(&m_skyTempYAxis, Qt::AlignLeft);
|
||||
series->attachAxis(&m_skyTempYAxis);
|
||||
|
||||
if (sunSeries) {
|
||||
sunSeries->attachAxis(&m_skyTempYAxis);
|
||||
}
|
||||
@ -1356,6 +1421,7 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
{
|
||||
m_chart.addAxis(&m_skyTempRAXAxis, Qt::AlignBottom);
|
||||
series->attachAxis(&m_skyTempRAXAxis);
|
||||
|
||||
if (sunSeries) {
|
||||
sunSeries->attachAxis(&m_skyTempRAXAxis);
|
||||
}
|
||||
@ -1366,6 +1432,7 @@ void StarTrackerGUI::plotSkyTemperatureChart()
|
||||
m_skyTempYAxis.setTitleText(QString("Declination (%1)").arg(QChar(0xb0)));
|
||||
m_chart.addAxis(&m_skyTempYAxis, Qt::AlignLeft);
|
||||
series->attachAxis(&m_skyTempYAxis);
|
||||
|
||||
if (sunSeries) {
|
||||
sunSeries->attachAxis(&m_skyTempYAxis);
|
||||
}
|
||||
@ -1392,6 +1459,7 @@ void StarTrackerGUI::plotAreaChanged(const QRectF &plotArea)
|
||||
|
||||
// Scale the image to fit plot area
|
||||
int imageIdx = ui->chartSubSelect->currentIndex();
|
||||
|
||||
if (imageIdx == -1) {
|
||||
return;
|
||||
} else if (imageIdx == 6) {
|
||||
@ -1399,6 +1467,7 @@ void StarTrackerGUI::plotAreaChanged(const QRectF &plotArea)
|
||||
} else if (imageIdx == 7) {
|
||||
imageIdx = 3;
|
||||
}
|
||||
|
||||
QImage image = m_images[imageIdx].scaled(QSize(width, height), Qt::IgnoreAspectRatio);
|
||||
QImage translated(viewW, viewH, QImage::Format_ARGB32);
|
||||
translated.fill(Qt::white);
|
||||
@ -1413,11 +1482,16 @@ void StarTrackerGUI::removeAllAxes()
|
||||
{
|
||||
QList<QAbstractAxis *> axes;
|
||||
axes = m_chart.axes(Qt::Horizontal);
|
||||
for (QAbstractAxis *axis : axes)
|
||||
|
||||
for (QAbstractAxis *axis : axes) {
|
||||
m_chart.removeAxis(axis);
|
||||
}
|
||||
|
||||
axes = m_chart.axes(Qt::Vertical);
|
||||
for (QAbstractAxis *axis : axes)
|
||||
|
||||
for (QAbstractAxis *axis : axes) {
|
||||
m_chart.removeAxis(axis);
|
||||
}
|
||||
}
|
||||
|
||||
// Plot target elevation angle over the day
|
||||
@ -1457,15 +1531,19 @@ void StarTrackerGUI::plotElevationLineChart()
|
||||
azSeries->setPen(pen);
|
||||
|
||||
QDateTime dt;
|
||||
if (m_settings.m_dateTime.isEmpty())
|
||||
|
||||
if (m_settings.m_dateTime.isEmpty()) {
|
||||
dt = QDateTime::currentDateTime();
|
||||
else
|
||||
} else {
|
||||
dt = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs);
|
||||
}
|
||||
|
||||
dt.setTime(QTime(0,0));
|
||||
QDateTime startTime = dt;
|
||||
QDateTime endTime = dt;
|
||||
double prevAz;
|
||||
int timestep = 10*60;
|
||||
|
||||
for (int step = 0; step <= 24*60*60/timestep; step++)
|
||||
{
|
||||
AzAlt aa;
|
||||
@ -1473,9 +1551,13 @@ void StarTrackerGUI::plotElevationLineChart()
|
||||
|
||||
// Calculate elevation of desired object
|
||||
if (m_settings.m_target == "Sun")
|
||||
{
|
||||
Astronomy::sunPosition(aa, rd, m_settings.m_latitude, m_settings.m_longitude, dt);
|
||||
}
|
||||
else if (m_settings.m_target == "Moon")
|
||||
{
|
||||
Astronomy::moonPosition(aa, rd, m_settings.m_latitude, m_settings.m_longitude, dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
rd.ra = Astronomy::raToDecimal(m_settings.m_ra);
|
||||
@ -1483,27 +1565,40 @@ void StarTrackerGUI::plotElevationLineChart()
|
||||
aa = Astronomy::raDecToAzAlt(rd, m_settings.m_latitude, m_settings.m_longitude, dt, !m_settings.m_jnow);
|
||||
}
|
||||
|
||||
if (aa.alt > maxElevation)
|
||||
if (aa.alt > maxElevation) {
|
||||
maxElevation = aa.alt;
|
||||
}
|
||||
|
||||
// Adjust for refraction
|
||||
if (m_settings.m_refraction == "Positional Astronomy Library")
|
||||
{
|
||||
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 += 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)
|
||||
|
||||
if (aa.alt > 90.0) {
|
||||
aa.alt = 90.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (step == 0)
|
||||
if (step == 0) {
|
||||
prevAz = aa.az;
|
||||
}
|
||||
|
||||
if (((prevAz >= 270) && (aa.az < 90)) || ((prevAz < 90) && (aa.az >= 270)))
|
||||
{
|
||||
@ -1514,21 +1609,23 @@ void StarTrackerGUI::plotElevationLineChart()
|
||||
|
||||
elSeries->append(dt.toMSecsSinceEpoch(), aa.alt);
|
||||
azSeries->append(dt.toMSecsSinceEpoch(), aa.az);
|
||||
|
||||
endTime = dt;
|
||||
prevAz = aa.az;
|
||||
dt = dt.addSecs(timestep); // addSecs accounts for daylight savings jumps
|
||||
}
|
||||
|
||||
m_azElLineChart->addAxis(xAxis, Qt::AlignBottom);
|
||||
m_azElLineChart->addAxis(yLeftAxis, Qt::AlignLeft);
|
||||
m_azElLineChart->addAxis(yRightAxis, Qt::AlignRight);
|
||||
m_azElLineChart->addSeries(elSeries);
|
||||
|
||||
for (int i = 0; i < azSeriesList.size(); i++)
|
||||
{
|
||||
m_azElLineChart->addSeries(azSeriesList[i]);
|
||||
azSeriesList[i]->attachAxis(xAxis);
|
||||
azSeriesList[i]->attachAxis(yRightAxis);
|
||||
}
|
||||
|
||||
elSeries->attachAxis(xAxis);
|
||||
elSeries->attachAxis(yLeftAxis);
|
||||
xAxis->setTitleText(QString("%1 %2").arg(startTime.date().toString()).arg(startTime.timeZoneAbbreviation()));
|
||||
@ -1539,12 +1636,14 @@ void StarTrackerGUI::plotElevationLineChart()
|
||||
yLeftAxis->setTitleText(QString("Elevation (%1)").arg(QChar(0xb0)));
|
||||
yRightAxis->setRange(0.0, 360.0);
|
||||
yRightAxis->setTitleText(QString("Azimuth (%1)").arg(QChar(0xb0)));
|
||||
if (maxElevation < 0)
|
||||
m_azElLineChart->setTitle("Not visible from this latitude");
|
||||
else
|
||||
m_azElLineChart->setTitle("");
|
||||
ui->chart->setChart(m_azElLineChart);
|
||||
|
||||
if (maxElevation < 0) {
|
||||
m_azElLineChart->setTitle("Not visible from this latitude");
|
||||
} else {
|
||||
m_azElLineChart->setTitle("");
|
||||
}
|
||||
|
||||
ui->chart->setChart(m_azElLineChart);
|
||||
delete oldChart;
|
||||
}
|
||||
|
||||
@ -1592,10 +1691,13 @@ void StarTrackerGUI::plotElevationPolarChart()
|
||||
|
||||
QLineSeries *polarSeries = new QLineSeries();
|
||||
QDateTime dt;
|
||||
if (m_settings.m_dateTime.isEmpty())
|
||||
|
||||
if (m_settings.m_dateTime.isEmpty()) {
|
||||
dt = QDateTime::currentDateTime();
|
||||
else
|
||||
} else {
|
||||
dt = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs);
|
||||
}
|
||||
|
||||
dt.setTime(QTime(0,0));
|
||||
QDateTime startTime = dt;
|
||||
QDateTime endTime = dt;
|
||||
@ -1606,6 +1708,7 @@ void StarTrackerGUI::plotElevationPolarChart()
|
||||
int idx = 0;
|
||||
int timestep = 10*60; // Rise/set times accurate to nearest 10 minutes
|
||||
double prevAlt;
|
||||
|
||||
for (int step = 0; step <= 24*60*60/timestep; step++)
|
||||
{
|
||||
AzAlt aa;
|
||||
@ -1613,9 +1716,13 @@ void StarTrackerGUI::plotElevationPolarChart()
|
||||
|
||||
// Calculate elevation of desired object
|
||||
if (m_settings.m_target == "Sun")
|
||||
{
|
||||
Astronomy::sunPosition(aa, rd, m_settings.m_latitude, m_settings.m_longitude, dt);
|
||||
}
|
||||
else if (m_settings.m_target == "Moon")
|
||||
{
|
||||
Astronomy::moonPosition(aa, rd, m_settings.m_latitude, m_settings.m_longitude, dt);
|
||||
}
|
||||
else
|
||||
{
|
||||
rd.ra = Astronomy::raToDecimal(m_settings.m_ra);
|
||||
@ -1623,27 +1730,40 @@ void StarTrackerGUI::plotElevationPolarChart()
|
||||
aa = Astronomy::raDecToAzAlt(rd, m_settings.m_latitude, m_settings.m_longitude, dt, !m_settings.m_jnow);
|
||||
}
|
||||
|
||||
if (aa.alt > maxElevation)
|
||||
if (aa.alt > maxElevation) {
|
||||
maxElevation = aa.alt;
|
||||
}
|
||||
|
||||
// Adjust for refraction
|
||||
if (m_settings.m_refraction == "Positional Astronomy Library")
|
||||
{
|
||||
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 += 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)
|
||||
|
||||
if (aa.alt > 90.0) {
|
||||
aa.alt = 90.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (idx == 0)
|
||||
if (idx == 0) {
|
||||
prevAlt = aa.alt;
|
||||
}
|
||||
|
||||
// We can have set before rise in a day, if the object starts > 0
|
||||
if ((aa.alt >= 0.0) && (prevAlt < 0.0))
|
||||
@ -1651,6 +1771,7 @@ void StarTrackerGUI::plotElevationPolarChart()
|
||||
riseTime = dt;
|
||||
riseIdx = idx;
|
||||
}
|
||||
|
||||
if ((aa.alt < 0.0) && (prevAlt >= 0.0))
|
||||
{
|
||||
setTime = endTime;
|
||||
@ -1659,10 +1780,8 @@ void StarTrackerGUI::plotElevationPolarChart()
|
||||
|
||||
polarSeries->append(aa.az, 90 - aa.alt);
|
||||
idx++;
|
||||
|
||||
endTime = dt;
|
||||
prevAlt = aa.alt;
|
||||
|
||||
dt = dt.addSecs(timestep); // addSecs accounts for daylight savings jumps
|
||||
}
|
||||
|
||||
@ -1676,10 +1795,12 @@ void StarTrackerGUI::plotElevationPolarChart()
|
||||
|
||||
qreal prevAz = polarSeries->at(0).x();
|
||||
qreal prevEl = polarSeries->at(0).y();
|
||||
|
||||
for (int i = 1; i < polarSeries->count(); i++)
|
||||
{
|
||||
qreal az = polarSeries->at(i).x();
|
||||
qreal el = polarSeries->at(i).y();
|
||||
|
||||
if ((prevAz > 270.0) && (az <= 90.0))
|
||||
{
|
||||
double elMid = Interpolation::interpolate(prevAz, prevEl, az+360.0, el, 360.0);
|
||||
@ -1701,7 +1822,10 @@ void StarTrackerGUI::plotElevationPolarChart()
|
||||
s->append(az, el);
|
||||
}
|
||||
else
|
||||
{
|
||||
s->append(polarSeries->at(i));
|
||||
}
|
||||
|
||||
prevAz = az;
|
||||
prevEl = el;
|
||||
}
|
||||
@ -1739,10 +1863,12 @@ void StarTrackerGUI::plotElevationPolarChart()
|
||||
setSeries->attachAxis(radialAxis);
|
||||
}
|
||||
|
||||
if (maxElevation < 0)
|
||||
if (maxElevation < 0) {
|
||||
m_azElPolarChart->setTitle("Not visible from this latitude");
|
||||
else
|
||||
} else {
|
||||
m_azElPolarChart->setTitle("");
|
||||
}
|
||||
|
||||
ui->chart->setChart(m_azElPolarChart);
|
||||
|
||||
delete polarSeries;
|
||||
@ -1775,6 +1901,7 @@ void StarTrackerGUI::on_chartSelect_currentIndexChanged(int index)
|
||||
{
|
||||
bool oldState = ui->chartSubSelect->blockSignals(true);
|
||||
ui->chartSubSelect->clear();
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
ui->chartSubSelect->addItem("Az/El vs time");
|
||||
@ -1798,6 +1925,7 @@ void StarTrackerGUI::on_chartSelect_currentIndexChanged(int index)
|
||||
ui->chartSubSelect->addItem("Milky Way");
|
||||
ui->chartSubSelect->addItem("Milky Way annotated");
|
||||
}
|
||||
|
||||
ui->chartSubSelect->blockSignals(oldState);
|
||||
plotChart();
|
||||
}
|
||||
@ -1844,32 +1972,45 @@ double StarTrackerGUI::calcSolarFlux(double freqMhz)
|
||||
double solarFlux;
|
||||
const int fluxes = sizeof(m_solarFluxFrequencies)/sizeof(*m_solarFluxFrequencies);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < fluxes; i++)
|
||||
{
|
||||
if (freqMhz < m_solarFluxFrequencies[i])
|
||||
if (freqMhz < m_solarFluxFrequencies[i]) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
solarFlux = Interpolation::extrapolate((double)m_solarFluxFrequencies[0], (double)m_solarFluxes[0],
|
||||
(double)m_solarFluxFrequencies[1], (double)m_solarFluxes[1],
|
||||
freqMhz
|
||||
);
|
||||
solarFlux = Interpolation::extrapolate(
|
||||
(double)m_solarFluxFrequencies[0],
|
||||
(double)m_solarFluxes[0],
|
||||
(double)m_solarFluxFrequencies[1],
|
||||
(double)m_solarFluxes[1],
|
||||
freqMhz
|
||||
);
|
||||
}
|
||||
else if (i == fluxes)
|
||||
{
|
||||
solarFlux = Interpolation::extrapolate((double)m_solarFluxFrequencies[fluxes-2], (double)m_solarFluxes[fluxes-2],
|
||||
(double)m_solarFluxFrequencies[fluxes-1], (double)m_solarFluxes[fluxes-1],
|
||||
freqMhz
|
||||
);
|
||||
solarFlux = Interpolation::extrapolate(
|
||||
(double)m_solarFluxFrequencies[fluxes-2],
|
||||
(double)m_solarFluxes[fluxes-2],
|
||||
(double)m_solarFluxFrequencies[fluxes-1],
|
||||
(double)m_solarFluxes[fluxes-1],
|
||||
freqMhz
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
solarFlux = Interpolation::interpolate((double)m_solarFluxFrequencies[i-1], (double)m_solarFluxes[i-1],
|
||||
(double)m_solarFluxFrequencies[i], (double)m_solarFluxes[i],
|
||||
freqMhz
|
||||
);
|
||||
solarFlux = Interpolation::interpolate(
|
||||
(double)m_solarFluxFrequencies[i-1],
|
||||
(double)m_solarFluxes[i-1],
|
||||
(double)m_solarFluxFrequencies[i],
|
||||
(double)m_solarFluxes[i],
|
||||
freqMhz
|
||||
);
|
||||
}
|
||||
|
||||
return solarFlux;
|
||||
}
|
||||
else
|
||||
@ -1881,7 +2022,7 @@ double StarTrackerGUI::calcSolarFlux(double freqMhz)
|
||||
void StarTrackerGUI::displaySolarFlux()
|
||||
{
|
||||
if (((m_settings.m_solarFluxData == StarTrackerSettings::DRAO_2800) && (m_solarFlux == 0.0))
|
||||
|| ((m_settings.m_solarFluxData != StarTrackerSettings::DRAO_2800) && !m_solarFluxesValid))
|
||||
|| ((m_settings.m_solarFluxData != StarTrackerSettings::DRAO_2800) && !m_solarFluxesValid))
|
||||
{
|
||||
ui->solarFlux->setText("");
|
||||
}
|
||||
@ -1889,6 +2030,7 @@ void StarTrackerGUI::displaySolarFlux()
|
||||
{
|
||||
double solarFlux;
|
||||
double freqMhz = m_settings.m_frequency/1000000.0;
|
||||
|
||||
if (m_settings.m_solarFluxData == StarTrackerSettings::DRAO_2800)
|
||||
{
|
||||
solarFlux = m_solarFlux;
|
||||
@ -1905,6 +2047,7 @@ void StarTrackerGUI::displaySolarFlux()
|
||||
solarFlux = m_solarFluxes[idx];
|
||||
ui->solarFlux->setToolTip(QString("Solar flux density at %1 MHz").arg(m_solarFluxFrequencies[idx]));
|
||||
}
|
||||
|
||||
ui->solarFlux->setText(QString("%1 %2").arg(convertSolarFluxUnits(solarFlux)).arg(solarFluxUnit()));
|
||||
ui->solarFlux->setCursorPosition(0);
|
||||
|
||||
@ -1917,6 +2060,7 @@ bool StarTrackerGUI::readSolarFlux()
|
||||
{
|
||||
QFile file(getSolarFluxFilename());
|
||||
QDateTime lastModified = file.fileTime(QFileDevice::FileModificationTime);
|
||||
|
||||
if (QDateTime::currentDateTime().secsTo(lastModified) >= -(60*60*24))
|
||||
{
|
||||
if (file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
@ -1927,6 +2071,7 @@ bool StarTrackerGUI::readSolarFlux()
|
||||
// 000000 000019 000027 000037 000056 000073 000116 000202 000514 sfu
|
||||
// Occasionally, file will contain ////// in a column, presumably to indicate no data
|
||||
QRegExp re("([0-9]{2})([0-9]{2})([0-9]{2}) ([0-9\\/]+) ([0-9\\/]+) ([0-9\\/]+) ([0-9\\/]+) ([0-9\\/]+) ([0-9\\/]+) ([0-9\\/]+) ([0-9\\/]+)");
|
||||
|
||||
if (re.indexIn(string) != -1)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
@ -1937,11 +2082,16 @@ bool StarTrackerGUI::readSolarFlux()
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "StarTrackerGUI::readSolarFlux: No match for " << string;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "StarTrackerGUI::readSolarFlux: Solar flux data is more than 1 day old";
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1953,21 +2103,24 @@ void StarTrackerGUI::networkManagerFinished(QNetworkReply *reply)
|
||||
if (replyError)
|
||||
{
|
||||
qWarning() << "StarTrackerGUI::networkManagerFinished:"
|
||||
<< " error(" << (int) replyError
|
||||
<< "): " << replyError
|
||||
<< ": " << reply->errorString();
|
||||
<< " error(" << (int) replyError
|
||||
<< "): " << replyError
|
||||
<< ": " << reply->errorString();
|
||||
}
|
||||
else
|
||||
{
|
||||
QString answer = reply->readAll();
|
||||
QRegExp re("\\<th\\>Observed Flux Density\\<\\/th\\>\\<td\\>([0-9]+(\\.[0-9]+)?)\\<\\/td\\>");
|
||||
|
||||
if (re.indexIn(answer) != -1)
|
||||
{
|
||||
m_solarFlux = re.capturedTexts()[1].toDouble();
|
||||
displaySolarFlux();
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "StarTrackerGUI::networkManagerFinished - No Solar flux found: " << answer;
|
||||
}
|
||||
}
|
||||
|
||||
reply->deleteLater();
|
||||
@ -1981,10 +2134,12 @@ QString StarTrackerGUI::getSolarFluxFilename()
|
||||
void StarTrackerGUI::updateSolarFlux(bool all)
|
||||
{
|
||||
qDebug() << "StarTrackerGUI: Updating Solar flux data";
|
||||
|
||||
if ((m_settings.m_solarFluxData != StarTrackerSettings::DRAO_2800) || all)
|
||||
{
|
||||
QDate today = QDateTime::currentDateTimeUtc().date();
|
||||
QString solarFluxFile = getSolarFluxFilename();
|
||||
|
||||
if (m_dlm.confirmDownload(solarFluxFile, nullptr, 0))
|
||||
{
|
||||
QString urlString = QString("https://www.sws.bom.gov.au/Category/World Data Centre/Data Display and Download/Solar Radio/station/learmonth/SRD/%1/L%2.SRD")
|
||||
@ -1992,6 +2147,7 @@ void StarTrackerGUI::updateSolarFlux(bool all)
|
||||
m_dlm.download(QUrl(urlString), solarFluxFile, this);
|
||||
}
|
||||
}
|
||||
|
||||
if ((m_settings.m_solarFluxData == StarTrackerSettings::DRAO_2800) || all)
|
||||
{
|
||||
m_networkRequest.setUrl(QUrl("https://www.spaceweather.gc.ca/forecast-prevision/solar-solaire/solarflux/sx-4-en.php"));
|
||||
@ -2012,11 +2168,14 @@ void StarTrackerGUI::on_downloadSolarFlux_clicked()
|
||||
void StarTrackerGUI::on_darkTheme_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_chartsDarkTheme = checked;
|
||||
|
||||
if (m_solarFluxChart) {
|
||||
m_solarFluxChart->setTheme(m_settings.m_chartsDarkTheme ? QChart::ChartThemeDark : QChart::ChartThemeLight);
|
||||
}
|
||||
|
||||
m_chart.setTheme(m_settings.m_chartsDarkTheme ? QChart::ChartThemeDark : QChart::ChartThemeLight);
|
||||
plotChart();
|
||||
m_settingsKeys.append("chartsDarkTheme");
|
||||
applySettings();
|
||||
}
|
||||
|
||||
@ -2024,6 +2183,7 @@ void StarTrackerGUI::on_drawSun_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_drawSunOnSkyTempChart = checked;
|
||||
plotChart();
|
||||
m_settingsKeys.append("drawSunOnSkyTempChart");
|
||||
applySettings();
|
||||
}
|
||||
|
||||
@ -2031,14 +2191,17 @@ void StarTrackerGUI::on_drawMoon_clicked(bool checked)
|
||||
{
|
||||
m_settings.m_drawMoonOnSkyTempChart = checked;
|
||||
plotChart();
|
||||
m_settingsKeys.append("drawMoonOnSkyTempChart");
|
||||
applySettings();
|
||||
}
|
||||
|
||||
void StarTrackerGUI::downloadFinished(const QString& filename, bool success)
|
||||
{
|
||||
(void) filename;
|
||||
if (success)
|
||||
|
||||
if (success) {
|
||||
readSolarFlux();
|
||||
}
|
||||
}
|
||||
|
||||
void StarTrackerGUI::makeUIConnections()
|
||||
|
@ -78,6 +78,7 @@ private:
|
||||
PluginAPI* m_pluginAPI;
|
||||
FeatureUISet* m_featureUISet;
|
||||
StarTrackerSettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
RollupState m_rollupState;
|
||||
bool m_doApplySettings;
|
||||
|
||||
|
@ -236,3 +236,282 @@ bool StarTrackerSettings::deserialize(const QByteArray& data)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
void StarTrackerSettings::applySettings(const QStringList& settingsKeys, const StarTrackerSettings& settings)
|
||||
{
|
||||
if (settingsKeys.contains("ra")) {
|
||||
m_ra = settings.m_ra;
|
||||
}
|
||||
if (settingsKeys.contains("dec")) {
|
||||
m_dec = settings.m_dec;
|
||||
}
|
||||
if (settingsKeys.contains("latitude")) {
|
||||
m_latitude = settings.m_latitude;
|
||||
}
|
||||
if (settingsKeys.contains("longitude")) {
|
||||
m_longitude = settings.m_longitude;
|
||||
}
|
||||
if (settingsKeys.contains("target")) {
|
||||
m_target = settings.m_target;
|
||||
}
|
||||
if (settingsKeys.contains("dateTime")) {
|
||||
m_dateTime = settings.m_dateTime;
|
||||
}
|
||||
if (settingsKeys.contains("refraction")) {
|
||||
m_refraction = settings.m_refraction;
|
||||
}
|
||||
if (settingsKeys.contains("pressure")) {
|
||||
m_pressure = settings.m_pressure;
|
||||
}
|
||||
if (settingsKeys.contains("temperature")) {
|
||||
m_temperature = settings.m_temperature;
|
||||
}
|
||||
if (settingsKeys.contains("humidity")) {
|
||||
m_humidity = settings.m_humidity;
|
||||
}
|
||||
if (settingsKeys.contains("heightAboveSeaLevel")) {
|
||||
m_heightAboveSeaLevel = settings.m_heightAboveSeaLevel;
|
||||
}
|
||||
if (settingsKeys.contains("temperatureLapseRate")) {
|
||||
m_temperatureLapseRate = settings.m_temperatureLapseRate;
|
||||
}
|
||||
if (settingsKeys.contains("frequency")) {
|
||||
m_frequency = settings.m_frequency;
|
||||
}
|
||||
if (settingsKeys.contains("beamwidth")) {
|
||||
m_beamwidth = settings.m_beamwidth;
|
||||
}
|
||||
if (settingsKeys.contains("enableServer")) {
|
||||
m_enableServer = settings.m_enableServer;
|
||||
}
|
||||
if (settingsKeys.contains("serverPort")) {
|
||||
m_serverPort = settings.m_serverPort;
|
||||
}
|
||||
if (settingsKeys.contains("azElUnits")) {
|
||||
m_azElUnits = settings.m_azElUnits;
|
||||
}
|
||||
if (settingsKeys.contains("solarFluxData")) {
|
||||
m_solarFluxData = settings.m_solarFluxData;
|
||||
}
|
||||
if (settingsKeys.contains("solarFluxUnits")) {
|
||||
m_solarFluxUnits = settings.m_solarFluxUnits;
|
||||
}
|
||||
if (settingsKeys.contains("updatePeriod")) {
|
||||
m_updatePeriod = settings.m_updatePeriod;
|
||||
}
|
||||
if (settingsKeys.contains("jnow")) {
|
||||
m_jnow = settings.m_jnow;
|
||||
}
|
||||
if (settingsKeys.contains("drawSunOnMap")) {
|
||||
m_drawSunOnMap = settings.m_drawSunOnMap;
|
||||
}
|
||||
if (settingsKeys.contains("drawMoonOnMap")) {
|
||||
m_drawMoonOnMap = settings.m_drawMoonOnMap;
|
||||
}
|
||||
if (settingsKeys.contains("drawStarOnMap")) {
|
||||
m_drawStarOnMap = settings.m_drawStarOnMap;
|
||||
}
|
||||
if (settingsKeys.contains("chartsDarkTheme")) {
|
||||
m_chartsDarkTheme = settings.m_chartsDarkTheme;
|
||||
}
|
||||
if (settingsKeys.contains("title")) {
|
||||
m_title = settings.m_title;
|
||||
}
|
||||
if (settingsKeys.contains("rgbColor")) {
|
||||
m_rgbColor = settings.m_rgbColor;
|
||||
}
|
||||
if (settingsKeys.contains("useReverseAPI")) {
|
||||
m_useReverseAPI = settings.m_useReverseAPI;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIAddress")) {
|
||||
m_reverseAPIAddress = settings.m_reverseAPIAddress;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIPort")) {
|
||||
m_reverseAPIPort = settings.m_reverseAPIPort;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIPort")) {
|
||||
m_reverseAPIPort = settings.m_reverseAPIPort;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIFeatureSetIndex")) {
|
||||
m_reverseAPIFeatureSetIndex = settings.m_reverseAPIFeatureSetIndex;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIFeatureIndex")) {
|
||||
m_reverseAPIFeatureIndex = settings.m_reverseAPIFeatureIndex;
|
||||
}
|
||||
if (settingsKeys.contains("az")) {
|
||||
m_az = settings.m_az;
|
||||
}
|
||||
if (settingsKeys.contains("el")) {
|
||||
m_el = settings.m_el;
|
||||
}
|
||||
if (settingsKeys.contains("l")) {
|
||||
m_l = settings.m_l;
|
||||
}
|
||||
if (settingsKeys.contains("b")) {
|
||||
m_b = settings.m_b;
|
||||
}
|
||||
if (settingsKeys.contains("azOffset")) {
|
||||
m_azOffset = settings.m_azOffset;
|
||||
}
|
||||
if (settingsKeys.contains("elOffset")) {
|
||||
m_elOffset = settings.m_elOffset;
|
||||
}
|
||||
if (settingsKeys.contains("link")) {
|
||||
m_link = settings.m_link;
|
||||
}
|
||||
if (settingsKeys.contains("owmAPIKey")) {
|
||||
m_owmAPIKey = settings.m_owmAPIKey;
|
||||
}
|
||||
if (settingsKeys.contains("weatherUpdatePeriod")) {
|
||||
m_weatherUpdatePeriod = settings.m_weatherUpdatePeriod;
|
||||
}
|
||||
if (settingsKeys.contains("drawSunOnSkyTempChart")) {
|
||||
m_drawSunOnSkyTempChart = settings.m_drawSunOnSkyTempChart;
|
||||
}
|
||||
if (settingsKeys.contains("drawMoonOnSkyTempChart")) {
|
||||
m_drawMoonOnSkyTempChart = settings.m_drawMoonOnSkyTempChart;
|
||||
}
|
||||
if (settingsKeys.contains("workspaceIndex")) {
|
||||
m_workspaceIndex = settings.m_workspaceIndex;
|
||||
}
|
||||
}
|
||||
|
||||
QString StarTrackerSettings::getDebugString(const QStringList& settingsKeys, bool force) const
|
||||
{
|
||||
std::ostringstream ostr;
|
||||
|
||||
if (settingsKeys.contains("ra") || force) {
|
||||
ostr << " m_ra: " << m_ra.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("dec") || force) {
|
||||
ostr << " m_dec: " << m_dec.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("latitude") || force) {
|
||||
ostr << " m_latitude: " << m_latitude;
|
||||
}
|
||||
if (settingsKeys.contains("longitude") || force) {
|
||||
ostr << " m_longitude: " << m_longitude;
|
||||
}
|
||||
if (settingsKeys.contains("target") || force) {
|
||||
ostr << " m_target: " << m_target.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("dateTime") || force) {
|
||||
ostr << " m_dateTime: " << m_dateTime.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("refraction") || force) {
|
||||
ostr << " m_refraction: " << m_refraction.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("pressure") || force) {
|
||||
ostr << " m_pressure: " << m_pressure;
|
||||
}
|
||||
if (settingsKeys.contains("temperature") || force) {
|
||||
ostr << " m_temperature: " << m_temperature;
|
||||
}
|
||||
if (settingsKeys.contains("humidity") || force) {
|
||||
ostr << " m_humidity: " << m_humidity;
|
||||
}
|
||||
if (settingsKeys.contains("heightAboveSeaLevel") || force) {
|
||||
ostr << " m_heightAboveSeaLevel: " << m_heightAboveSeaLevel;
|
||||
}
|
||||
if (settingsKeys.contains("temperatureLapseRate") || force) {
|
||||
ostr << " m_temperatureLapseRate: " << m_temperatureLapseRate;
|
||||
}
|
||||
if (settingsKeys.contains("frequency") || force) {
|
||||
ostr << " m_frequency: " << m_frequency;
|
||||
}
|
||||
if (settingsKeys.contains("beamwidth") || force) {
|
||||
ostr << " m_beamwidth: " << m_beamwidth;
|
||||
}
|
||||
if (settingsKeys.contains("enableServer") || force) {
|
||||
ostr << " m_enableServer: " << m_enableServer;
|
||||
}
|
||||
if (settingsKeys.contains("serverPort") || force) {
|
||||
ostr << " m_serverPort: " << m_serverPort;
|
||||
}
|
||||
if (settingsKeys.contains("azElUnits") || force) {
|
||||
ostr << " m_azElUnits: " << m_azElUnits;
|
||||
}
|
||||
if (settingsKeys.contains("solarFluxData") || force) {
|
||||
ostr << " m_solarFluxData: " << m_solarFluxData;
|
||||
}
|
||||
if (settingsKeys.contains("solarFluxUnits") || force) {
|
||||
ostr << " m_solarFluxUnits: " << m_solarFluxUnits;
|
||||
}
|
||||
if (settingsKeys.contains("updatePeriod") || force) {
|
||||
ostr << " m_updatePeriod: " << m_updatePeriod;
|
||||
}
|
||||
if (settingsKeys.contains("jnow") || force) {
|
||||
ostr << " m_jnow: " << m_jnow;
|
||||
}
|
||||
if (settingsKeys.contains("drawSunOnMap") || force) {
|
||||
ostr << " m_drawSunOnMap: " << m_drawSunOnMap;
|
||||
}
|
||||
if (settingsKeys.contains("drawMoonOnMap") || force) {
|
||||
ostr << " m_drawMoonOnMap: " << m_drawMoonOnMap;
|
||||
}
|
||||
if (settingsKeys.contains("drawStarOnMap") || force) {
|
||||
ostr << " m_drawStarOnMap: " << m_drawStarOnMap;
|
||||
}
|
||||
if (settingsKeys.contains("chartsDarkTheme") || force) {
|
||||
ostr << " m_chartsDarkTheme: " << m_chartsDarkTheme;
|
||||
}
|
||||
if (settingsKeys.contains("title") || force) {
|
||||
ostr << " m_title: " << m_title.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("rgbColor") || force) {
|
||||
ostr << " m_rgbColor: " << m_rgbColor;
|
||||
}
|
||||
if (settingsKeys.contains("useReverseAPI") || force) {
|
||||
ostr << " m_useReverseAPI: " << m_useReverseAPI;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIAddress") || force) {
|
||||
ostr << " m_reverseAPIAddress: " << m_reverseAPIAddress.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIPort") || force) {
|
||||
ostr << " m_reverseAPIPort: " << m_reverseAPIPort;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIFeatureSetIndex") || force) {
|
||||
ostr << " m_reverseAPIFeatureSetIndex: " << m_reverseAPIFeatureSetIndex;
|
||||
}
|
||||
if (settingsKeys.contains("reverseAPIFeatureIndex") || force) {
|
||||
ostr << " m_reverseAPIFeatureIndex: " << m_reverseAPIFeatureIndex;
|
||||
}
|
||||
if (settingsKeys.contains("az") || force) {
|
||||
ostr << " m_az: " << m_az;
|
||||
}
|
||||
if (settingsKeys.contains("el") || force) {
|
||||
ostr << " m_el: " << m_el;
|
||||
}
|
||||
if (settingsKeys.contains("l") || force) {
|
||||
ostr << " m_l: " << m_l;
|
||||
}
|
||||
if (settingsKeys.contains("b") || force) {
|
||||
ostr << " m_b: " << m_b;
|
||||
}
|
||||
if (settingsKeys.contains("azOffset") || force) {
|
||||
ostr << " m_azOffset: " << m_azOffset;
|
||||
}
|
||||
if (settingsKeys.contains("elOffset") || force) {
|
||||
ostr << " m_elOffset: " << m_elOffset;
|
||||
}
|
||||
if (settingsKeys.contains("link") || force) {
|
||||
ostr << " m_link: " << m_link;
|
||||
}
|
||||
if (settingsKeys.contains("owmAPIKey") || force) {
|
||||
ostr << " m_owmAPIKey: " << m_owmAPIKey.toStdString();
|
||||
}
|
||||
if (settingsKeys.contains("weatherUpdatePeriod") || force) {
|
||||
ostr << " m_weatherUpdatePeriod: " << m_weatherUpdatePeriod;
|
||||
}
|
||||
if (settingsKeys.contains("drawSunOnSkyTempChart") || force) {
|
||||
ostr << " m_drawSunOnSkyTempChart: " << m_drawSunOnSkyTempChart;
|
||||
}
|
||||
if (settingsKeys.contains("drawMoonOnSkyTempChart") || force) {
|
||||
ostr << " m_drawMoonOnSkyTempChart: " << m_drawMoonOnSkyTempChart;
|
||||
}
|
||||
if (settingsKeys.contains("workspaceIndex") || force) {
|
||||
ostr << " m_workspaceIndex: " << m_workspaceIndex;
|
||||
}
|
||||
|
||||
return QString(ostr.str().c_str());
|
||||
}
|
||||
|
@ -80,6 +80,8 @@ struct StarTrackerSettings
|
||||
QByteArray serialize() const;
|
||||
bool deserialize(const QByteArray& data);
|
||||
void setRollupState(Serializable *rollupState) { m_rollupState = rollupState; }
|
||||
void applySettings(const QStringList& settingsKeys, const StarTrackerSettings& settings);
|
||||
QString getDebugString(const QStringList& settingsKeys, bool force=false) const;
|
||||
|
||||
static const QStringList m_pipeTypes;
|
||||
static const QStringList m_pipeURIs;
|
||||
|
@ -18,10 +18,14 @@
|
||||
#include "startrackersettingsdialog.h"
|
||||
#include <QDebug>
|
||||
|
||||
StarTrackerSettingsDialog::StarTrackerSettingsDialog(StarTrackerSettings *settings,
|
||||
QWidget* parent) :
|
||||
StarTrackerSettingsDialog::StarTrackerSettingsDialog(
|
||||
StarTrackerSettings *settings,
|
||||
QList<QString>& settingsKeys,
|
||||
QWidget* parent
|
||||
) :
|
||||
QDialog(parent),
|
||||
m_settings(settings),
|
||||
m_settingsKeys(settingsKeys),
|
||||
ui(new Ui::StarTrackerSettingsDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@ -69,5 +73,25 @@ void StarTrackerSettingsDialog::accept()
|
||||
m_settings->m_drawSunOnMap = ui->drawSunOnMap->isChecked();
|
||||
m_settings->m_drawMoonOnMap = ui->drawMoonOnMap->isChecked();
|
||||
m_settings->m_drawStarOnMap = ui->drawStarOnMap->isChecked();
|
||||
|
||||
m_settingsKeys.append("jnow");
|
||||
m_settingsKeys.append("azElUnits");
|
||||
m_settingsKeys.append("updatePeriod");
|
||||
m_settingsKeys.append("serverPort");
|
||||
m_settingsKeys.append("enableServer");
|
||||
m_settingsKeys.append("refraction");
|
||||
m_settingsKeys.append("owmAPIKey");
|
||||
m_settingsKeys.append("weatherUpdatePeriod");
|
||||
m_settingsKeys.append("pressure");
|
||||
m_settingsKeys.append("temperature");
|
||||
m_settingsKeys.append("humidity");
|
||||
m_settingsKeys.append("heightAboveSeaLevel");
|
||||
m_settingsKeys.append("temperatureLapseRate");
|
||||
m_settingsKeys.append("solarFluxData");
|
||||
m_settingsKeys.append("solarFluxUnits");
|
||||
m_settingsKeys.append("drawSunOnMap");
|
||||
m_settingsKeys.append("drawMoonOnMap");
|
||||
m_settingsKeys.append("drawStarOnMap");
|
||||
|
||||
QDialog::accept();
|
||||
}
|
||||
|
@ -25,10 +25,11 @@ class StarTrackerSettingsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit StarTrackerSettingsDialog(StarTrackerSettings* settings, QWidget* parent = 0);
|
||||
explicit StarTrackerSettingsDialog(StarTrackerSettings* settings, QList<QString>& settingsKeys, QWidget* parent = 0);
|
||||
~StarTrackerSettingsDialog();
|
||||
|
||||
StarTrackerSettings *m_settings;
|
||||
QList<QString>& m_settingsKeys;
|
||||
|
||||
private slots:
|
||||
void accept();
|
||||
|
@ -100,7 +100,7 @@ bool StarTrackerWorker::handleMessage(const Message& cmd)
|
||||
QMutexLocker mutexLocker(&m_mutex);
|
||||
MsgConfigureStarTrackerWorker& cfg = (MsgConfigureStarTrackerWorker&) cmd;
|
||||
|
||||
applySettings(cfg.getSettings(), cfg.getForce());
|
||||
applySettings(cfg.getSettings(), cfg.getSettingsKeys(), cfg.getForce());
|
||||
return true;
|
||||
}
|
||||
else if (StarTracker::MsgSetSolarFlux::match(cmd))
|
||||
@ -115,65 +115,68 @@ bool StarTrackerWorker::handleMessage(const Message& cmd)
|
||||
}
|
||||
}
|
||||
|
||||
void StarTrackerWorker::applySettings(const StarTrackerSettings& settings, bool force)
|
||||
void StarTrackerWorker::applySettings(const StarTrackerSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||
{
|
||||
qDebug() << "StarTrackerWorker::applySettings:"
|
||||
<< " m_target: " << settings.m_target
|
||||
<< " m_ra: " << settings.m_ra
|
||||
<< " m_dec: " << settings.m_dec
|
||||
<< " m_time: " << settings.m_dateTime
|
||||
<< " m_enableServer: " << settings.m_enableServer
|
||||
<< " m_serverPort: " << settings.m_serverPort
|
||||
<< " m_updatePeriod: " << settings.m_updatePeriod
|
||||
<< " force: " << force;
|
||||
qDebug() << "StarTrackerWorker::applySettings:" << settings.getDebugString(settingsKeys, force) << " force: " << force;
|
||||
|
||||
if ( (m_settings.m_ra != settings.m_ra)
|
||||
|| (m_settings.m_dec != settings.m_dec)
|
||||
|| (m_settings.m_latitude != settings.m_latitude)
|
||||
|| (m_settings.m_longitude != settings.m_longitude)
|
||||
|| (m_settings.m_target != settings.m_target)
|
||||
|| (m_settings.m_dateTime != settings.m_dateTime)
|
||||
|| (m_settings.m_refraction != settings.m_refraction)
|
||||
|| (m_settings.m_pressure != settings.m_pressure)
|
||||
|| (m_settings.m_temperature != settings.m_temperature)
|
||||
|| (m_settings.m_humidity != settings.m_humidity)
|
||||
|| (m_settings.m_heightAboveSeaLevel != settings.m_heightAboveSeaLevel)
|
||||
|| (m_settings.m_temperatureLapseRate != settings.m_temperatureLapseRate)
|
||||
|| (m_settings.m_frequency != settings.m_frequency)
|
||||
|| (m_settings.m_beamwidth != settings.m_beamwidth)
|
||||
|| (m_settings.m_az != settings.m_az)
|
||||
|| (m_settings.m_el != settings.m_el)
|
||||
|| (m_settings.m_l != settings.m_l)
|
||||
|| (m_settings.m_b != settings.m_b)
|
||||
|| (m_settings.m_azOffset != settings.m_azOffset)
|
||||
|| (m_settings.m_elOffset != settings.m_elOffset)
|
||||
if (settingsKeys.contains("ra")
|
||||
|| settingsKeys.contains("dec")
|
||||
|| settingsKeys.contains("latitude")
|
||||
|| settingsKeys.contains("longitude")
|
||||
|| settingsKeys.contains("target")
|
||||
|| settingsKeys.contains("dateTime")
|
||||
|| settingsKeys.contains("refraction")
|
||||
|| settingsKeys.contains("pressure")
|
||||
|| settingsKeys.contains("temperature")
|
||||
|| settingsKeys.contains("humidity")
|
||||
|| settingsKeys.contains("heightAboveSeaLevel")
|
||||
|| settingsKeys.contains("temperatureLapseRate")
|
||||
|| settingsKeys.contains("frequency")
|
||||
|| settingsKeys.contains("beamwidth")
|
||||
|| settingsKeys.contains("az")
|
||||
|| settingsKeys.contains("el")
|
||||
|| settingsKeys.contains("l")
|
||||
|| settingsKeys.contains("b")
|
||||
|| settingsKeys.contains("azOffset")
|
||||
|| settingsKeys.contains("elOffset")
|
||||
|| force)
|
||||
{
|
||||
// Recalculate immediately
|
||||
QTimer::singleShot(1, this, &StarTrackerWorker::update);
|
||||
m_pollTimer.start((int)round(settings.m_updatePeriod*1000.0));
|
||||
}
|
||||
else if ((m_settings.m_updatePeriod != settings.m_updatePeriod) || force)
|
||||
else if (settingsKeys.contains("updatePeriod") || force)
|
||||
{
|
||||
m_pollTimer.start((int)round(settings.m_updatePeriod*1000.0));
|
||||
}
|
||||
|
||||
if (!settings.m_drawSunOnMap && m_settings.m_drawSunOnMap)
|
||||
removeFromMap("Sun");
|
||||
if (!settings.m_drawMoonOnMap && m_settings.m_drawMoonOnMap)
|
||||
removeFromMap("Moon");
|
||||
if ((!settings.m_drawStarOnMap && m_settings.m_drawStarOnMap)
|
||||
|| (((settings.m_target == "Sun") || (settings.m_target == "Moon"))
|
||||
&& ((m_settings.m_target != "Sun") && (m_settings.m_target != "Moon"))))
|
||||
removeFromMap("Star");
|
||||
if (settingsKeys.contains("drawSunOnMap")
|
||||
|| settingsKeys.contains("drawMoonOnMap")
|
||||
|| settingsKeys.contains("drawStarOnMap")
|
||||
|| settingsKeys.contains("m_target"))
|
||||
{
|
||||
if (!settings.m_drawSunOnMap && m_settings.m_drawSunOnMap)
|
||||
removeFromMap("Sun");
|
||||
if (!settings.m_drawMoonOnMap && m_settings.m_drawMoonOnMap)
|
||||
removeFromMap("Moon");
|
||||
if ((!settings.m_drawStarOnMap && m_settings.m_drawStarOnMap)
|
||||
|| (((settings.m_target == "Sun") || (settings.m_target == "Moon"))
|
||||
&& ((m_settings.m_target != "Sun") && (m_settings.m_target != "Moon"))))
|
||||
removeFromMap("Star");
|
||||
}
|
||||
|
||||
if ((settings.m_serverPort != m_settings.m_serverPort) ||
|
||||
(settings.m_enableServer != m_settings.m_enableServer) || force)
|
||||
|
||||
if (settingsKeys.contains("serverPort") ||
|
||||
settingsKeys.contains("enableServer") || force)
|
||||
{
|
||||
restartServer(settings.m_enableServer, settings.m_serverPort);
|
||||
}
|
||||
|
||||
m_settings = settings;
|
||||
if (force) {
|
||||
m_settings = settings;
|
||||
} else {
|
||||
m_settings.applySettings(settingsKeys, settings);
|
||||
}
|
||||
}
|
||||
|
||||
void StarTrackerWorker::restartServer(bool enabled, uint32_t port)
|
||||
|
@ -45,20 +45,23 @@ public:
|
||||
|
||||
public:
|
||||
const StarTrackerSettings& getSettings() const { return m_settings; }
|
||||
const QList<QString>& getSettingsKeys() const { return m_settingsKeys; }
|
||||
bool getForce() const { return m_force; }
|
||||
|
||||
static MsgConfigureStarTrackerWorker* create(const StarTrackerSettings& settings, bool force)
|
||||
static MsgConfigureStarTrackerWorker* create(const StarTrackerSettings& settings, const QList<QString>& settingsKeys, bool force)
|
||||
{
|
||||
return new MsgConfigureStarTrackerWorker(settings, force);
|
||||
return new MsgConfigureStarTrackerWorker(settings, settingsKeys, force);
|
||||
}
|
||||
|
||||
private:
|
||||
StarTrackerSettings m_settings;
|
||||
QList<QString> m_settingsKeys;
|
||||
bool m_force;
|
||||
|
||||
MsgConfigureStarTrackerWorker(const StarTrackerSettings& settings, bool force) :
|
||||
MsgConfigureStarTrackerWorker(const StarTrackerSettings& settings, const QList<QString>& settingsKeys, bool force) :
|
||||
Message(),
|
||||
m_settings(settings),
|
||||
m_settingsKeys(settingsKeys),
|
||||
m_force(force)
|
||||
{ }
|
||||
};
|
||||
@ -86,7 +89,7 @@ private:
|
||||
float m_solarFlux;
|
||||
|
||||
bool handleMessage(const Message& cmd);
|
||||
void applySettings(const StarTrackerSettings& settings, bool force = false);
|
||||
void applySettings(const StarTrackerSettings& settings, const QList<QString>& settingsKeys, bool force = false);
|
||||
void restartServer(bool enabled, uint32_t port);
|
||||
MessageQueue *getMessageQueueToGUI() { return m_msgQueueToGUI; }
|
||||
void updateRaDec(RADec rd, QDateTime dt, bool lbTarget);
|
||||
|
Loading…
Reference in New Issue
Block a user