Skip to content

nmeasim::app

namespace nmeasim::app · Applications

The Qt Widgets desktop application: the main window, its dock panels, the map, the instruments and the settings dialog, built on nmeasim::io.

Namespaces

Namespace Description
nmeasim::app::map The slippy-map view of the desktop application, part of nmeasim::app.
nmeasim::app::theme The look of the desktop application: the Theme singleton with its night-bridge and daylight looks and the option to follow the desktop, and the code-painted icons.

Types

Type Description
AppSettings Persistent application preferences (not the simulation profile), stored with QSettings in the platform's native location.
CompassDial North-up compass rose: the heading as a vessel-shaped pointer, the course over ground and the bearing to the destination as markers on the ring, and the three values as readouts.
ConsoleWidget Scrolling view of the sentences being sent, coloured like a protocol analyser.
DashboardWidget The instruments: a compass rose and a wind dial with the position, time and GNSS tiles on top, the grid of digital tiles below.
DialWidget Common look of the round instruments: a square widget with a bezel, a ring of ticks and a caption, painted in the colours of the current theme.
EngineTile One engine on the dashboard: its label, a running switch and editable revolutions and coolant temperature.
InstrumentTile One instrument on the dashboard: a caption, a large digital readout with its unit and, for controllable values, an override checkbox with a spin box.
MainWindow 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).
OutputsPage Settings tab with the list of outputs and an editor for the selected one.
OutputsWidget Table of the configured outputs with their live status.
SentenceHighlighter Colours the console like a protocol analyser, using sentence_spans and the colours of the current theme; it re-colours everything when the theme changes.
SentencesPage Settings tab that lists every sentence in the registry with its enabled flag, talker and period, plus the position precision.
SentenceSpan A run of characters in one role.
SettingsDialog Modal dialog that edits a copy of a profile in four tabs and applies the edits on OK.
SimulationPage Settings tab for the simulation mode, the profile name, the clock, the vessel seed values, their drift and the steering model.
StatusLed A coloured indicator light with a short upper-case caption, as on an instrument panel: the run state, recording and the outputs in the status bar.
VesselPage Settings tab for the engines and the AIS static data of the own vessel.
WindDial Wind instrument relative to the bow: port and starboard close-hauled sectors, the apparent wind as an arrow and the true wind as a hollow marker, with angles and speeds as readouts.

Summary

Enumerations

Name Description
SentenceRole The parts of a console line that are coloured differently.
Parameter A value the operator can override or nudge while the simulation runs.

Functions

Name Description
format_position() Formats a position as degrees and decimal minutes with hemisphere letters.
signed_relative_angle() Folds an angle relative to the bow into (-180, 180], negative to port.
format_wind_angle() Formats a wind angle relative to the bow as sailors say it: 104°P, 30°S, 0° ahead or 180° astern.
state_color() Returns the colour of an output state in the current theme: green open, amber opening, red failed, grey closed.
sentence_spans() Splits a console line into coloured runs.

Enumerations

SentenceRole

enum class SentenceRole

The parts of a console line that are coloured differently.

Each role has its own colour in theme::Colors.

Enumerator Value Description
Tag An IEC 61162-450 TAG block, from its opening backslash to its closing backslash inclusive. Coloured in console_tag.
Talker The $ or ! start delimiter and the talker identifier, for example $GP or !AI; only $P for a proprietary sentence. Coloured in console_talker.
Formatter The sentence formatter, for example RMC, or the rest of a proprietary address after $P, for example GRMZ. Coloured in console_formatter, in bold.
Separator A comma between fields. Coloured in console_separator.
Checksum The * and the two checksum digits. Coloured in console_checksum.
Json A JSON message such as a Signal K delta, coloured as a whole in console_json.

Declared in src/app/widgets/sentence_highlighter.hpp:24

Parameter

enum class Parameter

A value the operator can override or nudge while the simulation runs.

Each enumerator names a field of model::VesselState. A value written through an override or a nudge is normalised or clamped as stated for each enumerator.

Declared in src/app/main_window.cpp:65 · defined in src/core/include/nmeasim/core/simulation/delta_source.hpp:27

Functions

format_position()

QString format_position(const core::geo::Position& position)

Formats a position as degrees and decimal minutes with hemisphere letters.

Latitude has two degree digits and longitude three, minutes have two integer digits and three decimals, and the two are separated by two spaces, for example 37°59.028'N 023°43.650'E.

Parameters

Name Type Description
position const core::geo::Position& Position in degrees, latitude positive north, longitude positive east.

Returns QString: The formatted position.

Declared in src/app/widgets/dashboard_widget.hpp:96 · defined in src/app/widgets/dashboard_widget.cpp:131

signed_relative_angle()

double signed_relative_angle(double relative_deg) noexcept

Folds an angle relative to the bow into (-180, 180], negative to port.

Parameters

Name Type Description
relative_deg double Angle clockwise from the bow, in degrees; any finite value, including negative values and values of 360 or more.

Returns double: The same direction in (-180, 180]: 0 dead ahead, positive to starboard, negative to port, 180 dead astern.

Declared in src/app/widgets/dials.hpp:28 · defined in src/app/widgets/dials.cpp:51

format_wind_angle()

QString format_wind_angle(double relative_deg)

Formats a wind angle relative to the bow as sailors say it: 104°P, 30°S, 0° ahead or 180° astern.

The angle is folded with signed_relative_angle and rounded to whole degrees; the side letter is P for port and S for starboard, and is left out when the rounded angle is 0 or 180. For example 255.8 gives 104°P and 359.6 gives 0°.

Parameters

Name Type Description
relative_deg double Angle clockwise from the bow, in degrees; any finite value.

Returns QString: The rounded magnitude with a degree sign and, off the centreline, the side letter.

Declared in src/app/widgets/dials.hpp:39 · defined in src/app/widgets/dials.cpp:61

state_color()

QColor state_color(io::Transport::State state)

Returns the colour of an output state in the current theme: green open, amber opening, red failed, grey closed.

Parameters

Name Type Description
state io::Transport::State The transport state.

Returns QColor: The theme's ok, warning, danger or inactive colour; inactive also for a value outside the enumeration.

Declared in src/app/widgets/outputs_widget.hpp:23 · defined in src/app/widgets/outputs_widget.cpp:58

sentence_spans()

std::vector<SentenceSpan> sentence_spans(QStringView line)

Splits a console line into coloured runs.

A line that starts with { is one SentenceRole::Json span; its JSON is not checked. Otherwise an optional TAG block (from a leading backslash to the next one) comes first, then an NMEA 0183 or AIS sentence starting with $ or !. Its address runs to the first comma, or to the first * when there is none, or to the end of the line; the first three characters are the talker (two for $P, proprietary) and the rest the formatter. Every comma after the address and before the last * is a separator. The last * followed by two hexadecimal digits, of either case, is the checksum; its value is not verified, and a missing or malformed checksum is simply not coloured. Field contents are not listed; they keep the normal text colour.

The function is pure: it reads only line, in one pass, and allocates only the result, so it is cheap enough for every line the console shows and can be tested without a widget.

Parameters

Name Type Description
line QStringView One console line, without line terminator.

Returns std::vector<SentenceSpan>: The spans in ascending order of start, never overlapping. Empty for an empty line, a line with an unterminated TAG block and any line that is neither a sentence nor JSON; a TAG block followed by something other than a sentence gives only the SentenceRole::Tag span.

See also

  • NMEA 0183 (IEC 61162-1), sentence structure; IEC 61162-450, TAG blocks.

Declared in src/app/widgets/sentence_highlighter.hpp:80 · defined in src/app/widgets/sentence_highlighter.cpp:31