Skip to content

CompassDial

class nmeasim::app::CompassDial · Applications

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.

Inherits nmeasim::app::DialWidget

Declared in src/app/widgets/dials.hpp (line 145)

North is always at the top; the rose has ticks every 5 degrees, longer every 30, with the cardinal letters and the tens of degrees (3, 6, 12 and so on) inside the ring and N in the danger colour. The heading is the accent-coloured pointer, the course over ground a filled triangle in the ok colour and the bearing a diamond in the map's destination colour. The centre reads the heading (HDG °T), and below it COG and, with a destination, BRG. All angles are degrees true. The object name is compass_dial.

Summary

Public member functions

Name Description
CompassDial() Creates a compass showing heading and course 0 without a destination.
set_values() Sets the values to show and schedules a repaint.
heading() Returns the heading last set, degrees true.
course() Returns the course over ground last set, degrees true.
bearing() Returns the bearing to the destination last set, degrees true.

Protected member functions

Name Description
paintEvent() Paints the face, the ticks and labels, the bearing, course and heading markers in that order, so that the heading pointer lies on top, and then the readouts.

Private data members

Name Description
heading_deg_ Heading of the bow, degrees true.
course_deg_ Course over ground, degrees true.
bearing_deg_ Bearing to the destination, degrees true; std::nullopt without a destination.

Public member functions

CompassDial()

explicit CompassDial(QWidget* parent = nullptr)

Creates a compass showing heading and course 0 without a destination.

Parameters

Name Type Description
parent QWidget* Parent widget, which owns the dial; may be null, in which case the caller owns it.

Declared in src/app/widgets/dials.hpp:153 · defined in src/app/widgets/dials.cpp:147

set_values()

void set_values(double heading_deg, double course_deg, std::optional<double> bearing_deg)

Sets the values to show and schedules a repaint.

Values are drawn as given, without normalising; the readouts show them with one decimal and three integer digits, so they are expected in [0, 360).

Parameters

Name Type Description
heading_deg double Heading of the bow, degrees true.
course_deg double Course over ground, degrees true.
bearing_deg std::optional<double> Bearing from the vessel to the destination, degrees true; std::nullopt hides the diamond and the BRG readout.

Declared in src/app/widgets/dials.hpp:164 · defined in src/app/widgets/dials.cpp:154

heading()

double heading() const noexcept

Returns the heading last set, degrees true.

Returns double: The heading_deg of the last set_values, 0 before the first.

Declared in src/app/widgets/dials.hpp:169

course()

double course() const noexcept

Returns the course over ground last set, degrees true.

Returns double: The course_deg of the last set_values, 0 before the first.

Declared in src/app/widgets/dials.hpp:173

bearing()

std::optional<double> bearing() const noexcept

Returns the bearing to the destination last set, degrees true.

Returns std::optional<double>: The bearing_deg of the last set_values; std::nullopt without a destination.

Declared in src/app/widgets/dials.hpp:178

Protected member functions

paintEvent()

void paintEvent(QPaintEvent* event) override

Paints the face, the ticks and labels, the bearing, course and heading markers in that order, so that the heading pointer lies on top, and then the readouts.

Parameters

Name Type Description
event QPaintEvent* Unused; the whole dial is repainted.

Declared in src/app/widgets/dials.hpp:185 · defined in src/app/widgets/dials.cpp:162

Private data members

heading_deg_

double heading_deg_{0.0}

Heading of the bow, degrees true.

Declared in src/app/widgets/dials.hpp:189

course_deg_

double course_deg_{0.0}

Course over ground, degrees true.

Declared in src/app/widgets/dials.hpp:191

bearing_deg_

std::optional<double> bearing_deg_

Bearing to the destination, degrees true; std::nullopt without a destination.

Declared in src/app/widgets/dials.hpp:193

Inherited members

From nmeasim::app::CompassDial: at(), centre(), DialWidget(), draw_face(), draw_readout(), draw_ring_marker(), draw_ticks(), hasHeightForWidth(), heightForWidth(), minimumSizeHint(), radius(), sizeHint()