From 0581b4c292dc19cee91077b141f568f874f47e54 Mon Sep 17 00:00:00 2001 From: Jon Beniston Date: Fri, 14 Apr 2023 16:15:11 +0100 Subject: [PATCH] Sat & Star tracker: Plot target on Az/El chart. For #1641 --- .../satellitetracker/satellitetrackergui.cpp | 31 ++++++++-- .../satellitetracker/satellitetrackersgp4.cpp | 9 +-- .../feature/startracker/startrackergui.cpp | 57 +++++++++++++++++-- 3 files changed, 83 insertions(+), 14 deletions(-) diff --git a/plugins/feature/satellitetracker/satellitetrackergui.cpp b/plugins/feature/satellitetracker/satellitetrackergui.cpp index 817498704..680d6b64a 100644 --- a/plugins/feature/satellitetracker/satellitetrackergui.cpp +++ b/plugins/feature/satellitetracker/satellitetrackergui.cpp @@ -132,6 +132,7 @@ bool SatelliteTrackerGUI::handleMessage(const Message& message) ui->azimuth->setText(convertDegreesToText(satState->m_azimuth)); ui->elevation->setText(convertDegreesToText(satState->m_elevation)); + plotChart(); if (satState->m_passes.size() > 0) { @@ -143,7 +144,6 @@ bool SatelliteTrackerGUI::handleMessage(const Message& message) m_nextTargetAOS = pass.m_aos; m_nextTargetLOS = pass.m_los; m_geostationarySatVisible = geostationary; - plotChart(); updateTimeToAOS(); } } @@ -1084,14 +1084,11 @@ void SatelliteTrackerGUI::plotPolarChart() m_polarChart->addSeries(nowSeries); nowSeries->attachAxis(angularAxis); nowSeries->attachAxis(radialAxis); - if (!redrawTime) { - redrawTime = 5000; - } } if (redrawTime > 0) { - // Redraw to show updated satellite position or rotator position + // Redraw to show updated rotator position m_redrawTimer.setSingleShot(true); m_redrawTimer.start(redrawTime); } @@ -1239,6 +1236,30 @@ void SatelliteTrackerGUI::plotAzElChart() azSeriesList[i]->attachAxis(yRightAxis); } + // Plot current target on elevation series + if (m_targetSatState && (m_targetSatState->m_elevation > 0.0)) + { + QDateTime currentTime; + + if (m_settings.m_dateTime == "") { + currentTime = m_satelliteTracker->currentDateTimeUtc(); + } else if (m_settings.m_utc) { + currentTime = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs); + } else { + currentTime = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs).toUTC(); + } + + QScatterSeries *posSeries = new QScatterSeries(); + posSeries->setMarkerSize(3); + posSeries->append(currentTime.toMSecsSinceEpoch(), m_targetSatState->m_elevation); + posSeries->setPointLabelsVisible(true); + posSeries->setPointLabelsFormat(m_settings.m_target); + posSeries->setPointLabelsClipping(false); + m_lineChart->addSeries(posSeries); + posSeries->attachAxis(xAxis); + posSeries->attachAxis(yLeftAxis); + } + xAxis->setRange(pass.m_aos, pass.m_los); xAxis->setFormat("hh:mm"); yLeftAxis->setRange(0.0, 90.0); diff --git a/plugins/feature/satellitetracker/satellitetrackersgp4.cpp b/plugins/feature/satellitetracker/satellitetrackersgp4.cpp index c8b1e2442..7b858a858 100644 --- a/plugins/feature/satellitetracker/satellitetrackersgp4.cpp +++ b/plugins/feature/satellitetracker/satellitetrackersgp4.cpp @@ -473,7 +473,8 @@ void getSatelliteState(QDateTime dateTime, QTime passStartTime, QTime passFinishTime, bool utc, int noOfPasses, int groundTrackSteps, SatelliteState *satState) { - try { + try + { Tle tle = Tle(tle0.toStdString(), tle1.toStdString(), tle2.toStdString()); SGP4 sgp4(tle); Observer obs(latitude, longitude, altitude); @@ -522,14 +523,14 @@ void getSatelliteState(QDateTime dateTime, } catch (SatelliteException& se) { - qDebug() << "getSatelliteState: " << satState->m_name << ": " << se.what(); + qDebug() << "getSatelliteState:SatelliteException " << satState->m_name << ": " << se.what(); } catch (DecayedException& de) { - qDebug() << "getSatelliteState: " << satState->m_name << ": " << de.what(); + qDebug() << "getSatelliteState:DecayedException " << satState->m_name << ": " << de.what(); } catch (TleException& tlee) { - qDebug() << "getSatelliteState: " << satState->m_name << ": " << tlee.what(); + qDebug() << "getSatelliteState:TleException " << satState->m_name << ": " << tlee.what() << "\n" << tle0 << "\n" << tle1 << "\n" << tle2; } } diff --git a/plugins/feature/startracker/startrackergui.cpp b/plugins/feature/startracker/startrackergui.cpp index 45a8ecff9..39b09ce87 100644 --- a/plugins/feature/startracker/startrackergui.cpp +++ b/plugins/feature/startracker/startrackergui.cpp @@ -1540,12 +1540,14 @@ void StarTrackerGUI::plotElevationLineChart() azSeries->setPen(pen); QDateTime dt; + QDateTime currentTime; if (m_settings.m_dateTime.isEmpty()) { - dt = QDateTime::currentDateTime(); + currentTime = QDateTime::currentDateTime(); } else { - dt = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs); + currentTime = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs); } + dt = currentTime; dt.setTime(QTime(0,0)); QDateTime startTime = dt; @@ -1635,6 +1637,28 @@ void StarTrackerGUI::plotElevationLineChart() azSeriesList[i]->attachAxis(yRightAxis); } + // Plot current target on elevation series + if (ui->azimuth->hasValue() && ui->elevation->hasValue() && (ui->elevation->value() > 0.0)) + { + QScatterSeries *posSeries = new QScatterSeries(); + posSeries->setMarkerSize(3); + posSeries->append(currentTime.toMSecsSinceEpoch(), ui->elevation->value()); + if (m_settings.m_target.startsWith("Custom")) + { + posSeries->setPointLabelsVisible(false); + posSeries->setPointLabelsFormat(""); + } + else + { + posSeries->setPointLabelsVisible(true); + posSeries->setPointLabelsFormat(m_settings.m_target); + } + posSeries->setPointLabelsClipping(false); + m_azElLineChart->addSeries(posSeries); + posSeries->attachAxis(xAxis); + posSeries->attachAxis(yLeftAxis); + } + elSeries->attachAxis(xAxis); elSeries->attachAxis(yLeftAxis); xAxis->setTitleText(QString("%1 %2").arg(startTime.date().toString()).arg(startTime.timeZoneAbbreviation())); @@ -1719,14 +1743,15 @@ void StarTrackerGUI::plotElevationPolarChart() double maxElevation = -90.0; QLineSeries *polarSeries = new QLineSeries(); + QDateTime currentTime; QDateTime dt; if (m_settings.m_dateTime.isEmpty()) { - dt = QDateTime::currentDateTime(); + currentTime = QDateTime::currentDateTime(); } else { - dt = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs); + currentTime = QDateTime::fromString(m_settings.m_dateTime, Qt::ISODateWithMs); } - + dt = currentTime; dt.setTime(QTime(0,0)); QDateTime startTime = dt; QDateTime endTime = dt; @@ -1978,6 +2003,28 @@ void StarTrackerGUI::plotElevationPolarChart() setSeries->attachAxis(radialAxis); } + // Plot target current position + if (ui->azimuth->hasValue() && ui->elevation->hasValue() && (ui->elevation->value() > 0.0)) + { + QScatterSeries *posSeries = new QScatterSeries(); + posSeries->setMarkerSize(3); + posSeries->append(ui->azimuth->value(), 90 - ui->elevation->value()); + if (m_settings.m_target.startsWith("Custom")) + { + posSeries->setPointLabelsVisible(false); + posSeries->setPointLabelsFormat(""); + } + else + { + posSeries->setPointLabelsVisible(true); + posSeries->setPointLabelsFormat(m_settings.m_target); + } + posSeries->setPointLabelsClipping(false); + m_azElPolarChart->addSeries(posSeries); + posSeries->attachAxis(angularAxis); + posSeries->attachAxis(radialAxis); + } + if (maxElevation < 0) { m_azElPolarChart->setTitle("Not visible from this latitude"); } else {