Skip to content

MainWindow

class nmeasim::app::MainWindow · Applications

Top-level window: a dashboard in the centre, dockable console, outputs and map panels, and a toolbar that controls the profile, the simulation and the transport (pause, step, seek).

Inherits QMainWindow

Declared in src/app/main_window.hpp (line 83)

Layout: the DashboardWidget is the central widget; the map::MapWidget docks on the left, the OutputsWidget on the right and the ConsoleWidget at the bottom, each in a QDockWidget the operator can move, float or hide. The status bar holds the run and recording lights, the profile name and mode, the outputs light and the sentence counter. The geometry and dock layout are restored from AppSettings at construction and saved in closeEvent.

Menus, in the order they appear in the menu bar (the Ctrl shortcuts use Cmd on macOS):

  • File: New profile (Ctrl+N), Open profile... (Ctrl+O), Save profile (Ctrl+S), Save profile as... (Ctrl+Shift+S), Open track... (Ctrl+T), Open log for replay... (Ctrl+L), Record log... (Ctrl+R), Settings... (Ctrl+comma) and Quit (Ctrl+Q).
  • Simulation: Start or Stop (F5), Pause (F6), Step (F7), Steering mode, Clear destination and Start automatically on launch.
  • Help: About.
  • View: the Map, Console and Outputs panels, Follow vessel on the map (Home), Download map tiles, Clear map tile cache and the Theme submenu.

The toolbar repeats Open, Save, Settings, Start, Pause, Step, Steering mode and Record, and ends with the seek slider and the position label. The arrow keys nudge the vessel; see keyPressEvent.

Profile: the window keeps its own copy of the current profile, which move_vessel and set_destination edit so that saving keeps those changes, and applies it to the runner whenever it is replaced. A profile that the runner rejects leaves the previous one in place.

Ownership: the window owns the runner and the settings by value. The tile cache, the dashboard, the console, the outputs table, the map, the status bar widgets, the docks and every action have the window as Qt parent and are deleted with it; the pointers returned by the accessors stay valid for the window's lifetime.

Threads: the window, its widgets and its runner all live on the GUI thread; every signal connected here is delivered there directly.

Errors meant for the operator are shown in the status bar for ten seconds, emitted as error_reported and, while the window is visible, shown in a message box, so that tests running offscreen never block on a dialog.

See also

  • docs/reference/desktop-app.md
  • docs/adr/0009-desktop-shell.md

Summary

Public member functions

Name Description
MainWindow() Builds the window, restores its layout and applies the built-in default profile.
~MainWindow() Destroys the window, stopping the simulation and closing its outputs first.
load_profile() Loads a profile file and makes it current.
open_initial_profile() Opens the profile to start with; called once by main after the window is shown.
save_profile_to() Writes the current profile to a file and makes that file the profile's file.
profile_path() Returns the file the current profile was loaded from or last saved to.
set_profile() Makes a profile current and applies it to the runner.
profile() Returns the current profile, including changes made on the map.
load_track() Switches the current profile to track mode with a track file.
load_log() Switches the current profile to replay mode with a log file.
set_recording() Records every emitted sentence to a log file.
start() Opens the outputs and starts ticking, unless the simulation is already running.
stop() Stops ticking and closes every output; the simulation keeps its state.
is_running() Returns whether the simulation is running.
runner() Returns the runner the window drives, for tests and for the outputs table.
dashboard() Returns the central dashboard.
console() Returns the sentence console of the Console dock.
outputs() Returns the outputs table of the Outputs dock.
map_view() Returns the map of the Map dock.
step_action() Returns the Step action (F7).
record_action() Returns the checkable Record log... action (Ctrl+R).
steering_action() Returns the checkable Steering mode action.
seek_slider() Returns the seek slider at the end of the toolbar.
position_label() Returns the label next to the seek slider.
run_led() Returns the run state light at the left of the status bar.
recording_led() Returns the recording light of the status bar.
outputs_led() Returns the outputs light at the right of the status bar.
theme_actions() Returns the View → Theme entries.
move_vessel() Moves the vessel to a position, both in the running simulation and in the profile seed so that saving keeps it.
set_destination() Steers for a waypoint at a position; the leg starts where the vessel is now.
clear_destination() Stops steering for the waypoint, in the running simulation and in the profile seed.
clear_destination_action() Returns the Simulation → Clear destination action.

Public static member functions

Name Description
about_text() Returns the rich text of the About dialog.
format_duration() Formats a duration for the position label.

Signals

Name Description
error_reported() Emitted for every error the window itself reports to the operator, so that hosts and tests can observe errors without a dialog.

Protected member functions

Name Description
keyPressEvent() Nudges the vessel with the arrow keys; other keys go to QMainWindow.
closeEvent() Saves the window geometry and dock layout and stops the simulation before the window closes.

Private member functions

Name Description
build_actions() Creates the File and Simulation menus, their actions and shortcuts, and the toolbar with the seek slider and position label, and connects each action to its slot.
build_docks() Puts the console, outputs and map into docks and creates the View menu, after Simulation, with the dock toggles, the map actions and the Theme submenu.
build_help_menu() Creates the Help menu with About, last in the menu bar.
apply_icons() Paints the action icons in the colours of the current theme.
report_error() Reports an error to the operator: ten seconds in the status bar, error_reported, and a warning box while the window is visible.
update_title() Sets the title to name - NMEA Simulator X, where the name is the profile file name or, for a profile without a file, the profile's own name.
update_actions() Brings the run controls in line with the run state.
refresh_status() Refreshes the status bar: the three lights, the profile name with its mode (and the track or log file name), and the sentence counter.
refresh_view() Refreshes the dashboard and the map from the current vessel state.
refresh_transport() Refreshes the seek slider and the position label from the runner.
nudge() Nudges a parameter of the delta source and updates the dashboard.
delta_source() Returns the current source when it is the delta simulation.
new_profile() Replaces the current profile with the built-in default; slot of New profile.
open_profile() Asks for a profile file in the profiles directory and loads it; slot of Open profile....
open_track() Asks for a GPX or KML file and calls load_track; slot of Open track....
open_log() Asks for a log file and calls load_log; slot of Open log for replay....
edit_settings() Opens the settings dialog on a copy of the current profile; slot of Settings....
save_profile() Writes the current profile to its file; slot of Save profile.
save_profile_as() Asks for a file name in the profiles directory and writes the profile there with save_profile_to; slot of Save profile as....
toggle_run() Stops a running simulation or starts a stopped one; slot of Start / Stop (F5).
toggle_pause() Pauses or resumes the run; slot of the checkable Pause action (F6).
toggle_steering() Switches between steering with the rudder and setting the heading; slot of the checkable Steering mode action.
toggle_recording() Starts or stops recording; slot of the checkable Record log... action.
seek_from_slider() Seeks the runner to the slider position; connected to QSlider::valueChanged.

Private data members

Name Description
settings_ Preferences read at construction and written when the operator changes them.
profile_ The current profile, as last applied or changed on the map; see profile.
profile_path_ File the current profile was loaded from or saved to; empty for a profile without a file.
runner_ The runner of the current profile; the outputs table observes it.
tile_cache_ Map tile store shared with the map; Qt child of the window.
dashboard_ Central widget with the instruments and override controls.
console_ Sentence console, in the Console dock.
outputs_ Outputs table, in the Outputs dock.
map_ Slippy map, in the Map dock.
status_label_ Status bar text: the profile name and, in track or replay mode, the file name.
counter_label_ Status bar counter of sentences emitted since the profile was applied, in the monospaced font.
seek_slider_ Toolbar slider over the length of a track or log; see seek_slider.
position_label_ Toolbar label with the elapsed and total time; see position_label.
run_led_ Run state light; see run_led.
recording_led_ Recording light; see recording_led.
outputs_led_ Outputs light; see outputs_led.
theme_actions_ The View → Theme entries; see theme_actions.
updating_slider_ True while refresh_transport sets the slider, so that seek_from_slider does not turn that update into a seek.
new_action_ File → New profile (Ctrl+N); calls new_profile.
open_action_ File → Open profile... (Ctrl+O); calls open_profile.
open_track_action_ File → Open track... (Ctrl+T); calls open_track.
open_log_action_ File → Open log for replay... (Ctrl+L); calls open_log.
record_action_ Checkable File → Record log... (Ctrl+R); calls toggle_recording.
step_action_ Simulation → Step (F7); steps the runner, which starts the run paused when stopped.
save_action_ File → Save profile (Ctrl+S); calls save_profile.
save_as_action_ File → Save profile as... (Ctrl+Shift+S); calls save_profile_as.
settings_action_ File → Settings... (Ctrl+comma); calls edit_settings.
run_action_ Simulation → Start / Stop (F5); calls toggle_run.
pause_action_ Checkable Simulation → Pause (F6); calls toggle_pause; enabled only while running.
steering_action_ Checkable Simulation → Steering mode; calls toggle_steering; enabled in delta mode.
clear_destination_action_ Simulation → Clear destination; calls clear_destination.
autostart_action_ Checkable Simulation → Start automatically on launch; stores simulation/autostart.
follow_action_ Checkable View → Follow vessel on the map (Home); kept in step with the map's own follow state in both directions.
online_tiles_action_ Checkable View → Download map tiles; switches the tile cache and stores map/online.

Public member functions

MainWindow()

explicit MainWindow(QWidget* parent = nullptr)

Builds the window, restores its layout and applies the built-in default profile.

Reads the map preferences (tiles online, tile URL, attribution, zoom) and the autostart flag from AppSettings, builds the actions, menus, toolbar, docks and status bar, and connects the map, dashboard, theme and runner signals. On a first start, when no dock layout was saved, it gives the map about 400 pixels, the outputs about 260 and the console about 170. The simulation is not started.

Parameters

Name Type Description
parent QWidget* Qt parent that owns the window; null for a top-level window, as main creates it.

Declared in src/app/main_window.hpp:97 · defined in src/app/main_window.cpp:67

~MainWindow()

~MainWindow() override

Destroys the window, stopping the simulation and closing its outputs first.

Declared in src/app/main_window.hpp:99 · defined in src/app/main_window.cpp:205

load_profile()

bool load_profile(const QString& path)

Loads a profile file and makes it current.

Stops a running simulation, applies the profile and starts it again, as set_profile does, and remembers path as the profile to reopen at the next start.

Parameters

Name Type Description
path const QString& Profile file in the JSON format of docs/reference/profile.md.

Returns bool: False when the file cannot be read or parsed, or when set_profile rejects the profile (for example a track file that is missing); the reason is reported (see error_reported) and the current profile stays. True when the profile is current.

Declared in src/app/main_window.hpp:110 · defined in src/app/main_window.cpp:598

open_initial_profile()

void open_initial_profile(const QString& requested)

Opens the profile to start with; called once by main after the window is shown.

Loads requested with load_profile when it is not empty. When it is empty, or it cannot be loaded (which load_profile reports), the profile stored under profile/last_path is loaded instead, provided that file exists. Otherwise the built-in default profile stays.

Parameters

Name Type Description
requested const QString& Profile path given on the command line; empty when none was given.

Declared in src/app/main_window.hpp:119 · defined in src/app/main_window.cpp:608

save_profile_to()

bool save_profile_to(const QString& path)

Writes the current profile to a file and makes that file the profile's file.

Only after a successful write does path become the file Save profile writes to, the one shown in the title and the profile to reopen at the next start; the saved path is shown in the status bar for three seconds. A failed write is reported (see error_reported) and changes nothing.

Parameters

Name Type Description
path const QString& File to write, in the JSON format of docs/reference/profile.md.

Returns bool: True when the profile was written; false when the write failed.

Declared in src/app/main_window.hpp:129 · defined in src/app/main_window.cpp:803

profile_path()

const QString& profile_path() const noexcept

Returns the file the current profile was loaded from or last saved to.

Returns const QString&: The path Save profile writes to; empty when the profile has no file yet.

Declared in src/app/main_window.hpp:133

set_profile()

bool set_profile(const io::Profile& profile, const QString& path = {})

Makes a profile current and applies it to the runner.

A running simulation is stopped, the profile applied and the run started again. On success the map's sailed track is cleared, the route of a track is drawn, the map is centred on the vessel, the dashboard overrides and Steering mode are enabled only in delta mode (in track and replay mode Steering mode is also unticked), the Rudder override is limited to the profile's maximum rudder angle, and the title, the transport controls and the outputs table are refreshed.

Parameters

Name Type Description
profile const io::Profile& The profile to use; copied.
path const QString& File the profile came from and Save profile writes to. Empty means the profile has no file yet: the title shows the profile name and Save profile asks for a file name. A non-empty path is also stored as the profile to reopen at the next start.

Returns bool: False when the runner cannot apply the profile (for example a track or log file that cannot be read); the reason is reported (see error_reported), the previous profile stays current and a run that was going is restarted with it. True otherwise.

Declared in src/app/main_window.hpp:151 · defined in src/app/main_window.cpp:621

profile()

const io::Profile& profile() const noexcept

Returns the current profile, including changes made on the map.

Returns const io::Profile&: The window's copy, valid until the next change of profile; it can differ from io::SimulationRunner::profile by the start position and destination that move_vessel, set_destination and clear_destination write into its seed.

Declared in src/app/main_window.hpp:157

load_track()

bool load_track(const QString& path)

Switches the current profile to track mode with a track file.

Copies the current profile, sets its mode to io::SimulationMode::Track and its track path, and applies it with set_profile, keeping the current profile file path.

Parameters

Name Type Description
path const QString& GPX 1.1 or KML 2.2 file, as docs/reference/track-files.md describes.

Returns bool: The result of set_profile: false, with the reason reported and the previous profile kept, when the file cannot be read or parsed.

Declared in src/app/main_window.hpp:167 · defined in src/app/main_window.cpp:446

load_log()

bool load_log(const QString& path)

Switches the current profile to replay mode with a log file.

Copies the current profile, sets its mode to io::SimulationMode::Replay and its replay path, and applies it with set_profile, keeping the current profile file path.

Parameters

Name Type Description
path const QString& Recorded or plain NMEA log, as docs/reference/log-format.md describes.

Returns bool: The result of set_profile: false, with the reason reported and the previous profile kept, when the file cannot be read.

Declared in src/app/main_window.hpp:176 · defined in src/app/main_window.cpp:453

set_recording()

bool set_recording(const QString& path)

Records every emitted sentence to a log file.

Passes the path to io::SimulationRunner::set_recording; the runner's recording_changed signal then ticks or unticks Record log... and updates the status bar. While stopped the file opens only at the next start, so a bad path is reported by the runner then, in the status bar.

Parameters

Name Type Description
path const QString& Log file, truncated when the recording opens; empty stops recording.

Returns bool: False when the file was opened at once and that failed: the error is reported (see error_reported) and the recording is cleared. True otherwise.

Declared in src/app/main_window.hpp:187 · defined in src/app/main_window.cpp:460

start()

void start()

Opens the outputs and starts ticking, unless the simulation is already running.

Clears the console, starts the runner, carries the Steering mode state into a delta source, updates the dashboard's override controls and gives the window keyboard focus so that the arrow keys steer at once. The toolbar and status bar follow through the runner's started signal.

Declared in src/app/main_window.hpp:195 · defined in src/app/main_window.cpp:673

stop()

void stop()

Stops ticking and closes every output; the simulation keeps its state.

Also unticks Pause. Safe to call when not running.

Declared in src/app/main_window.hpp:199 · defined in src/app/main_window.cpp:686

is_running()

bool is_running() const

Returns whether the simulation is running.

Returns bool: True between start and stop, paused or not.

Declared in src/app/main_window.hpp:203 · defined in src/app/main_window.cpp:691

runner()

io::SimulationRunner& runner() noexcept

Returns the runner the window drives, for tests and for the outputs table.

Returns io::SimulationRunner&: The runner owned by the window, valid for the window's lifetime.

Declared in src/app/main_window.hpp:208

dashboard()

DashboardWidget* dashboard() const noexcept

Returns the central dashboard.

Returns DashboardWidget*: The dashboard, owned by the window; never null.

Declared in src/app/main_window.hpp:212

console()

ConsoleWidget* console() const noexcept

Returns the sentence console of the Console dock.

Returns ConsoleWidget*: The console, owned by the window; never null.

Declared in src/app/main_window.hpp:216

outputs()

OutputsWidget* outputs() const noexcept

Returns the outputs table of the Outputs dock.

Returns OutputsWidget*: The outputs table, owned by the window; never null.

Declared in src/app/main_window.hpp:220

map_view()

map::MapWidget* map_view() const noexcept

Returns the map of the Map dock.

Returns map::MapWidget*: The map, owned by the window; never null.

Declared in src/app/main_window.hpp:224

step_action()

QAction* step_action() const noexcept

Returns the Step action (F7).

Returns QAction*: The action, owned by the window; never null after construction.

Declared in src/app/main_window.hpp:228

record_action()

QAction* record_action() const noexcept

Returns the checkable Record log... action (Ctrl+R).

Returns QAction*: The action, owned by the window; never null after construction.

Declared in src/app/main_window.hpp:232

steering_action()

QAction* steering_action() const noexcept

Returns the checkable Steering mode action.

Returns QAction*: The action, owned by the window; never null after construction. It is enabled in delta mode only.

Declared in src/app/main_window.hpp:237

seek_slider()

QSlider* seek_slider() const noexcept

Returns the seek slider at the end of the toolbar.

Returns QSlider*: The slider, owned by the window; never null. Its range is the length of the track or log in milliseconds; it is disabled with an empty range for the delta simulation.

Declared in src/app/main_window.hpp:243

position_label()

QLabel* position_label() const noexcept

Returns the label next to the seek slider.

Returns QLabel*: The label, owned by the window; never null. It shows the elapsed and total time as 03:00 / 12:00, and is empty for the delta simulation.

Declared in src/app/main_window.hpp:248

run_led()

StatusLed* run_led() const noexcept

Returns the run state light at the left of the status bar.

Returns StatusLed*: The light, owned by the window; green RUNNING, amber PAUSED or unlit STOPPED. Null only during construction.

Declared in src/app/main_window.hpp:253

recording_led()

StatusLed* recording_led() const noexcept

Returns the recording light of the status bar.

Returns StatusLed*: The light, owned by the window: a red REC, visible only while recording and blinking while the run is going and not paused. Null only during construction.

Declared in src/app/main_window.hpp:258

outputs_led()

StatusLed* outputs_led() const noexcept

Returns the outputs light at the right of the status bar.

Returns StatusLed*: The light, owned by the window, captioned n/m OUTPUTS: while running, green when every output is open, red when one failed and amber otherwise; unlit when stopped or without outputs. Null only during construction.

Declared in src/app/main_window.hpp:264

theme_actions()

QList<QAction *> theme_actions() const

Returns the View → Theme entries.

Returns QList<QAction *>: Three checkable actions in one exclusive group, in the order Follow the system, Night bridge (dark) and Daylight (light); each carries its stored name (system, night, day) as data. Owned by the window.

Declared in src/app/main_window.hpp:270

move_vessel()

void move_vessel(core::geo::Position position)

Moves the vessel to a position, both in the running simulation and in the profile seed so that saving keeps it.

A destination's leg restarts at the new position, the sailed track on the map starts a new segment instead of drawing a line from the old place, and the map recentres. Shows the new position in the status bar for three seconds. Connected to map::MapWidget::position_picked.

Parameters

Name Type Description
position core::geo::Position The new position, latitude in [-90, 90] and longitude in [-180, 180].

Declared in src/app/main_window.hpp:295 · defined in src/app/main_window.cpp:320

set_destination()

void set_destination(core::geo::Position position, const QString& name = {})

Steers for a waypoint at a position; the leg starts where the vessel is now.

The destination is applied to the running source and kept in the profile seed. Its arrival radius is taken from the seed's previous destination, or the default of core::model::Destination when there was none. Clear destination becomes available and the status bar confirms for three seconds. Connected to map::MapWidget::destination_picked.

Parameters

Name Type Description
position core::geo::Position The waypoint, latitude in [-90, 90] and longitude in [-180, 180].
name const QString& Waypoint id sent in APB and RMB; empty gives WPT.

Declared in src/app/main_window.hpp:306 · defined in src/app/main_window.cpp:339

clear_destination()

void clear_destination()

Stops steering for the waypoint, in the running simulation and in the profile seed.

APB, RMB and XTE are no longer sent, and the status bar confirms for three seconds. Connected to the Clear destination action and to map::MapWidget::destination_cleared.

Declared in src/app/main_window.hpp:312 · defined in src/app/main_window.cpp:362

clear_destination_action()

QAction* clear_destination_action() const noexcept

Returns the Simulation → Clear destination action.

Returns QAction*: The action, owned by the window; enabled only while the vessel state has a destination. Never null after construction.

Declared in src/app/main_window.hpp:317

Public static member functions

about_text()

static QString about_text()

Returns the rich text of the About dialog.

Returns QString: The product name with core::version_description, which for a development build includes the git describe string of the commit, a one-line description and a link to the project repository.

Declared in src/app/main_window.hpp:277 · defined in src/app/main_window.cpp:371

format_duration()

static QString format_duration(std::chrono::milliseconds duration)

Formats a duration for the position label.

Parameters

Name Type Description
duration std::chrono::milliseconds The duration; negative values are shown as zero, and the fraction of a second is dropped.

Returns QString: mm:ss below one hour (01:05), h:mm:ss from one hour (3:07:09).

Declared in src/app/main_window.hpp:284 · defined in src/app/main_window.cpp:379

Signals

error_reported()

void error_reported(const QString& title, const QString& message)

Emitted for every error the window itself reports to the operator, so that hosts and tests can observe errors without a dialog.

Emitted synchronously from load_profile, set_profile (and so load_track, load_log and the settings dialog), set_recording and Save profile, before any message box opens. Errors of the outputs, which the runner reports through io::SimulationRunner::output_error, only reach the status bar and do not emit it.

Parameters

Name Type Description
title const QString& Short summary, such as Cannot open profile.
message const QString& The reason, as the profile loader, the runner or the file system gave it.

Declared in src/app/main_window.hpp:333

Protected member functions

keyPressEvent()

void keyPressEvent(QKeyEvent* event) override

Nudges the vessel with the arrow keys; other keys go to QMainWindow.

Up and Down change the speed over ground by 0.1 kn (1 kn with Shift). Left and Right change the heading by 1° (10° with Shift), or the rudder angle when Steering mode is on; Left is to port. A nudge pins the parameter as an override of the delta source. In track and replay mode, which have nothing to nudge, the arrow keys go to QMainWindow as well. The window receives them only while it or a child that ignores them has focus.

Parameters

Name Type Description
event QKeyEvent* The key press.

Declared in src/app/main_window.hpp:346 · defined in src/app/main_window.cpp:734

closeEvent()

void closeEvent(QCloseEvent* event) override

Saves the window geometry and dock layout and stops the simulation before the window closes.

Reached from File → Quit and from the window manager's close button.

Parameters

Name Type Description
event QCloseEvent* The close request, accepted by the base class.

Declared in src/app/main_window.hpp:353 · defined in src/app/main_window.cpp:762

Private member functions

build_actions()

void build_actions()

Creates the File and Simulation menus, their actions and shortcuts, and the toolbar with the seek slider and position label, and connects each action to its slot.

Declared in src/app/main_window.hpp:358 · defined in src/app/main_window.cpp:211

build_docks()

void build_docks()

Puts the console, outputs and map into docks and creates the View menu, after Simulation, with the dock toggles, the map actions and the Theme submenu.

Declared in src/app/main_window.hpp:361 · defined in src/app/main_window.cpp:512

build_help_menu()

void build_help_menu()

Creates the Help menu with About, last in the menu bar.

Declared in src/app/main_window.hpp:363 · defined in src/app/main_window.cpp:583

apply_icons()

void apply_icons()

Paints the action icons in the colours of the current theme.

Connected to theme::Theme::changed, since the icons are drawn rather than loaded.

Declared in src/app/main_window.hpp:367 · defined in src/app/main_window.cpp:833

report_error()

void report_error(const QString& title, const QString& message)

Reports an error to the operator: ten seconds in the status bar, error_reported, and a warning box while the window is visible.

Emits error_reported.

Parameters

Name Type Description
title const QString& Short summary, used as the box title.
message const QString& The reason.

Declared in src/app/main_window.hpp:375 · defined in src/app/main_window.cpp:817

update_title()

void update_title()

Sets the title to name - NMEA Simulator X, where the name is the profile file name or, for a profile without a file, the profile's own name.

Declared in src/app/main_window.hpp:378 · defined in src/app/main_window.cpp:827

update_actions()

void update_actions()

Brings the run controls in line with the run state.

Start becomes Stop (text and icon) while running, Pause is enabled only while running and unticked otherwise; then refreshes the transport controls and the status bar. Connected to the runner's started and stopped signals.

Declared in src/app/main_window.hpp:384 · defined in src/app/main_window.cpp:851

refresh_status()

void refresh_status()

Refreshes the status bar: the three lights, the profile name with its mode (and the track or log file name), and the sentence counter.

Called after every tick, on pause, recording and theme changes and from update_actions.

Declared in src/app/main_window.hpp:390 · defined in src/app/main_window.cpp:863

refresh_view()

void refresh_view()

Refreshes the dashboard and the map from the current vessel state.

Also enables Clear destination only while the state has a destination. Does nothing before a profile has been applied.

Declared in src/app/main_window.hpp:395 · defined in src/app/main_window.cpp:395

refresh_transport()

void refresh_transport()

Refreshes the seek slider and the position label from the runner.

The slider is enabled for a source of known, non-zero length and does not jump while the operator holds it. Step is enabled once a simulation exists.

Declared in src/app/main_window.hpp:400 · defined in src/app/main_window.cpp:413

nudge()

void nudge(core::simulation::Parameter parameter, double delta)

Nudges a parameter of the delta source and updates the dashboard.

Does nothing when the current source is not a delta source.

Parameters

Name Type Description
parameter core::simulation::Parameter The value to change.
delta double The change, in the parameter's unit (knots or degrees); negative to decrease.

Declared in src/app/main_window.hpp:408 · defined in src/app/main_window.cpp:726

delta_source()

core::simulation::DeltaSource* delta_source()

Returns the current source when it is the delta simulation.

Returns core::simulation::DeltaSource*: The runner's source, valid until the next successful set_profile; null in track and replay mode and before a profile has been applied.

Declared in src/app/main_window.hpp:413 · defined in src/app/main_window.cpp:591

new_profile()

void new_profile()

Replaces the current profile with the built-in default; slot of New profile.

The new profile has no file, so Save profile asks for a name.

Declared in src/app/main_window.hpp:418 · defined in src/app/main_window.cpp:768

open_profile()

void open_profile()

Asks for a profile file in the profiles directory and loads it; slot of Open profile....

Declared in src/app/main_window.hpp:421 · defined in src/app/main_window.cpp:779

open_track()

void open_track()

Asks for a GPX or KML file and calls load_track; slot of Open track....

The dialog starts in the folder of the current track, a relative path taken from the profile's directory (AppSettings::dialog_directory), or in the documents folder.

Declared in src/app/main_window.hpp:426 · defined in src/app/main_window.cpp:471

open_log()

void open_log()

Asks for a log file and calls load_log; slot of Open log for replay....

The dialog starts in the folder of the current log, a relative path taken from the profile's directory (AppSettings::dialog_directory), or in the documents folder.

Declared in src/app/main_window.hpp:431 · defined in src/app/main_window.cpp:481

edit_settings()

void edit_settings()

Opens the settings dialog on a copy of the current profile; slot of Settings....

OK applies the edited profile with set_profile, keeping its file path; Cancel discards it. The file on disk is not written.

Declared in src/app/main_window.hpp:436 · defined in src/app/main_window.cpp:772

save_profile()

bool save_profile()

Writes the current profile to its file; slot of Save profile.

Asks for a file name through save_profile_as when the profile has none, and writes through save_profile_to otherwise.

Returns bool: True when the profile was written; false when it failed or the operator cancelled the file dialog.

Declared in src/app/main_window.hpp:444 · defined in src/app/main_window.cpp:787

save_profile_as()

bool save_profile_as()

Asks for a file name in the profiles directory and writes the profile there with save_profile_to; slot of Save profile as....

Returns bool: True when the profile was written; false when the operator cancelled or the write failed.

Declared in src/app/main_window.hpp:450 · defined in src/app/main_window.cpp:794

toggle_run()

void toggle_run()

Stops a running simulation or starts a stopped one; slot of Start / Stop (F5).

Declared in src/app/main_window.hpp:452 · defined in src/app/main_window.cpp:695

toggle_pause()

void toggle_pause(bool paused)

Pauses or resumes the run; slot of the checkable Pause action (F6).

Parameters

Name Type Description
paused bool True to freeze the simulated clock, false to continue.

Declared in src/app/main_window.hpp:456 · defined in src/app/main_window.cpp:703

toggle_steering()

void toggle_steering(bool enabled)

Switches between steering with the rudder and setting the heading; slot of the checkable Steering mode action.

Leaving steering mode centres the rudder and releases its override, so the vessel stops turning. The dashboard enables the rudder or the heading control accordingly.

Parameters

Name Type Description
enabled bool True for the arrow keys to move the rudder.

Declared in src/app/main_window.hpp:464 · defined in src/app/main_window.cpp:712

toggle_recording()

void toggle_recording(bool checked)

Starts or stops recording; slot of the checkable Record log... action.

Ticking asks for a file, suggesting nmeasim-yyyyMMdd-HHmmss.log (UTC) in the documents folder, and calls set_recording; cancelling the dialog unticks the action again. Unticking stops the recording.

Parameters

Name Type Description
checked bool The new state of the action.

Declared in src/app/main_window.hpp:472 · defined in src/app/main_window.cpp:491

seek_from_slider()

void seek_from_slider(int value)

Seeks the runner to the slider position; connected to QSlider::valueChanged.

Ignores changes made by refresh_transport and changes while the slider is disabled. Starts a new segment of the sailed track on the map.

Parameters

Name Type Description
value int Position in the track or log, in milliseconds.

Declared in src/app/main_window.hpp:479 · defined in src/app/main_window.cpp:438

Private data members

settings_

AppSettings settings_

Preferences read at construction and written when the operator changes them.

Declared in src/app/main_window.hpp:482

profile_

io::Profile profile_{io::Profile::default_profile()}

The current profile, as last applied or changed on the map; see profile.

Declared in src/app/main_window.hpp:484

profile_path_

QString profile_path_

File the current profile was loaded from or saved to; empty for a profile without a file.

Declared in src/app/main_window.hpp:487

runner_

io::SimulationRunner runner_

The runner of the current profile; the outputs table observes it.

Declared in src/app/main_window.hpp:489

tile_cache_

map::TileCache* tile_cache_

Map tile store shared with the map; Qt child of the window.

Declared in src/app/main_window.hpp:493

dashboard_

DashboardWidget* dashboard_

Central widget with the instruments and override controls.

Declared in src/app/main_window.hpp:495

console_

ConsoleWidget* console_

Sentence console, in the Console dock.

Declared in src/app/main_window.hpp:497

outputs_

OutputsWidget* outputs_

Outputs table, in the Outputs dock.

Declared in src/app/main_window.hpp:499

map_

map::MapWidget* map_

Slippy map, in the Map dock.

Declared in src/app/main_window.hpp:501

status_label_

QLabel* status_label_

Status bar text: the profile name and, in track or replay mode, the file name.

Declared in src/app/main_window.hpp:503

counter_label_

QLabel* counter_label_

Status bar counter of sentences emitted since the profile was applied, in the monospaced font.

Declared in src/app/main_window.hpp:506

seek_slider_

QSlider* seek_slider_

Toolbar slider over the length of a track or log; see seek_slider.

Declared in src/app/main_window.hpp:508

position_label_

QLabel* position_label_

Toolbar label with the elapsed and total time; see position_label.

Declared in src/app/main_window.hpp:510

run_led_

StatusLed* run_led_{nullptr}

Run state light; see run_led.

Declared in src/app/main_window.hpp:512

recording_led_

StatusLed* recording_led_{nullptr}

Recording light; see recording_led.

Declared in src/app/main_window.hpp:514

outputs_led_

StatusLed* outputs_led_{nullptr}

Outputs light; see outputs_led.

Declared in src/app/main_window.hpp:516

theme_actions_

QList<QAction *> theme_actions_

The View → Theme entries; see theme_actions.

Declared in src/app/main_window.hpp:518

updating_slider_

bool updating_slider_{false}

True while refresh_transport sets the slider, so that seek_from_slider does not turn that update into a seek.

Declared in src/app/main_window.hpp:521

new_action_

QAction* new_action_{nullptr}

File → New profile (Ctrl+N); calls new_profile.

Declared in src/app/main_window.hpp:524

open_action_

QAction* open_action_{nullptr}

File → Open profile... (Ctrl+O); calls open_profile.

Declared in src/app/main_window.hpp:526

open_track_action_

QAction* open_track_action_{nullptr}

File → Open track... (Ctrl+T); calls open_track.

Declared in src/app/main_window.hpp:528

open_log_action_

QAction* open_log_action_{nullptr}

File → Open log for replay... (Ctrl+L); calls open_log.

Declared in src/app/main_window.hpp:530

record_action_

QAction* record_action_{nullptr}

Checkable File → Record log... (Ctrl+R); calls toggle_recording.

Declared in src/app/main_window.hpp:532

step_action_

QAction* step_action_{nullptr}

Simulation → Step (F7); steps the runner, which starts the run paused when stopped.

Declared in src/app/main_window.hpp:534

save_action_

QAction* save_action_{nullptr}

File → Save profile (Ctrl+S); calls save_profile.

Declared in src/app/main_window.hpp:536

save_as_action_

QAction* save_as_action_{nullptr}

File → Save profile as... (Ctrl+Shift+S); calls save_profile_as.

Declared in src/app/main_window.hpp:538

settings_action_

QAction* settings_action_{nullptr}

File → Settings... (Ctrl+comma); calls edit_settings.

Declared in src/app/main_window.hpp:540

run_action_

QAction* run_action_{nullptr}

Simulation → Start / Stop (F5); calls toggle_run.

Declared in src/app/main_window.hpp:542

pause_action_

QAction* pause_action_{nullptr}

Checkable Simulation → Pause (F6); calls toggle_pause; enabled only while running.

Declared in src/app/main_window.hpp:544

steering_action_

QAction* steering_action_{nullptr}

Checkable Simulation → Steering mode; calls toggle_steering; enabled in delta mode.

Declared in src/app/main_window.hpp:546

clear_destination_action_

QAction* clear_destination_action_{nullptr}

Simulation → Clear destination; calls clear_destination.

Declared in src/app/main_window.hpp:548

autostart_action_

QAction* autostart_action_{nullptr}

Checkable Simulation → Start automatically on launch; stores simulation/autostart.

Declared in src/app/main_window.hpp:550

follow_action_

QAction* follow_action_{nullptr}

Checkable View → Follow vessel on the map (Home); kept in step with the map's own follow state in both directions.

Declared in src/app/main_window.hpp:553

online_tiles_action_

QAction* online_tiles_action_{nullptr}

Checkable View → Download map tiles; switches the tile cache and stores map/online.

Declared in src/app/main_window.hpp:555