Enroute Flight Navigation
A navigation app for VFR pilots
Flightlog::FlightRecorder Class Reference

GPS track recorder and IGC file manager. More...

#include <FlightRecorder.h>

Signals

void trackGeoPathChanged ()
 Emitted when a new track point has been recorded.

Public Member Functions

 FlightRecorder (QObject *parent=nullptr)
 Standard constructor.
 ~FlightRecorder () override=default
 Standard destructor.
void processPositionUpdate (FlightDetector::DetectionState state, const Positioning::PositionInfo &info, Units::Distance pressureAltitude={})
 Process a position update with the current detection state.
bool saveTrack (Flight &flight)
 Save the recorded track to an IGC file.
void clearTrack ()
 Clear the in-memory track data.
auto loadTrackPath (const Flight &flight) const -> QList< QGeoCoordinate >
 Load a track's coordinates from an IGC file.
QByteArray exportToIGC (const Flight &flight) const
 Export a flight's track via the platform share dialog.
void removeTrack (Flight &flight)
 Delete the track file from disk.
auto trackGeoPath () const -> QGeoPath
 Get the current track as a list of coordinates.

Static Public Member Functions

static auto toIGC (const Flight &flight, const QList< TrackPoint > &track) -> QByteArray
 Generate IGC file content from flight metadata and track points.
static auto trackFromIGC (const QByteArray &igcData, const QDate &date={}) -> QList< TrackPoint >
 Parse track points from IGC file content.

Detailed Description

GPS track recorder and IGC file manager.

This class handles recording GPS track points during a flight, writing/reading IGC files, and exporting tracks via the platform share dialog. It applies distance and time filters to keep the number of recorded points reasonable.

Recording is driven by calling processPositionUpdate() with the current detection state on every position update. Track points are recorded during TakeoffPhase, InFlight, and LandingPhase states.

  • TakeoffPhase → abort (Idle): Track is discarded on next cycle.
  • LandingPhase → Idle: Recording ends. Track saving is handled externally by FlightLog::onLandingDetected.
  • LandingPhase → InFlight: Touch-and-go. FlightLog must call processPositionUpdate() on the recorder before the detector so each position is committed to the correct leg regardless of whether the landingDetected connection is direct or queued.

Definition at line 55 of file FlightRecorder.h.

Constructor & Destructor Documentation

◆ FlightRecorder()

Flightlog::FlightRecorder::FlightRecorder ( QObject * parent = nullptr)
explicit

Standard constructor.

Parameters
parentThe standard QObject parent pointer

Member Function Documentation

◆ clearTrack()

void Flightlog::FlightRecorder::clearTrack ( )

Clear the in-memory track data.

Frees the recorded track points from RAM. Call after saveTrack() and after caching the geo path for display.

◆ exportToIGC()

QByteArray Flightlog::FlightRecorder::exportToIGC ( const Flight & flight) const
nodiscard

Export a flight's track via the platform share dialog.

Reads the IGC file and returns its raw content.

Parameters
flightThe flight whose track to export
Returns
IGC file content, or empty if no track file or file not readable

◆ loadTrackPath()

auto Flightlog::FlightRecorder::loadTrackPath ( const Flight & flight) const -> QList< QGeoCoordinate >
nodiscard

Load a track's coordinates from an IGC file.

Reads the IGC file referenced by the flight's trackFile property and returns the coordinates for map display.

Parameters
flightThe flight whose track to load
Returns
List of coordinates from the track, or empty if not available

◆ processPositionUpdate()

void Flightlog::FlightRecorder::processPositionUpdate ( FlightDetector::DetectionState state,
const Positioning::PositionInfo & info,
Units::Distance pressureAltitude = {} )

Process a position update with the current detection state.

Call this on every position update when auto-detection is enabled. The recorder decides whether and where to record based on the detection state and internal state transitions.

Parameters
stateCurrent detection state from the FlightDetector
infoThe current position info
pressureAltitudePressure altitude, or an invalid Distance if unknown

◆ removeTrack()

void Flightlog::FlightRecorder::removeTrack ( Flight & flight)

Delete the track file from disk.

Removes the IGC file referenced by the flight's trackFile property and clears the trackFile. Does nothing if no trackFile is set.

Parameters
flightThe flight whose track to delete

◆ saveTrack()

bool Flightlog::FlightRecorder::saveTrack ( Flight & flight)

Save the recorded track to an IGC file.

Writes the recorder's in-memory track as an IGC file in the tracks directory, using metadata from the flight. Sets the trackFile property on the flight.

Parameters
flightThe flight whose metadata to use for the IGC headers
Returns
True if the track file was written successfully

◆ toIGC()

auto Flightlog::FlightRecorder::toIGC ( const Flight & flight,
const QList< TrackPoint > & track ) -> QByteArray
static

Generate IGC file content from flight metadata and track points.

Creates a complete IGC file with A-record, H-records (date, pilot, aircraft, recorder type), and B-records for each track point.

Parameters
flightThe flight whose metadata to use for headers
trackThe track points to write as B-records
Returns
IGC file content, or empty if no track

◆ trackFromIGC()

auto Flightlog::FlightRecorder::trackFromIGC ( const QByteArray & igcData,
const QDate & date = {} ) -> QList< TrackPoint >
static

Parse track points from IGC file content.

Reads B-records and extracts position, altitude, and timestamp for each fix. Parses H-record date if no date is provided.

Parameters
igcDataThe IGC file content
dateThe flight date (optional, parsed from H-record if empty)
Returns
List of parsed track points

◆ trackGeoPath()

auto Flightlog::FlightRecorder::trackGeoPath ( ) const -> QGeoPath
nodiscard

Get the current track as a list of coordinates.

Returns the coordinates of all recorded track points. Suitable for binding to a MapPolyline in QML.

Returns
List of coordinates from the current track

◆ trackGeoPathChanged

void Flightlog::FlightRecorder::trackGeoPathChanged ( )
signal

Emitted when a new track point has been recorded.

Use this to update the live track display on the map.


The documentation for this class was generated from the following file: