Skip to content

dials.cpp

file src/app/widgets/dials.cpp · Applications

Painting of the compass rose and the wind dial, and the wind angle helpers.

Source src/app/widgets/dials.cpp

Namespaces

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

Namespace members

Declared or defined in this file and documented on the page of their namespace.

Member Description
nmeasim::app::signed_relative_angle Folds an angle relative to the bow into (-180, 180], negative to port.
nmeasim::app::format_wind_angle Formats a wind angle relative to the bow as sailors say it: 104°P, 30°S, 0° ahead or 180° astern.

Summary

File-local functions

Name Description
pixel_font() Returns a copy of a font sized in pixels, so that dial text scales with the dial.
degrees() Formats an angle for a compass readout with three integer digits and one decimal.

File-local variables

Name Description
kMargin Space between the tick ring and the widget edge, in pixels; the bezel takes 6 of them.
kDegreesToRadians Factor that converts degrees to radians.

File-local functions

pixel_font()

QFont pixel_font(const QFont& base, double pixels, bool bold)

Returns a copy of a font sized in pixels, so that dial text scales with the dial.

Parameters

Name Type Description
base const QFont& Font to copy the family and style from.
pixels double Text height in pixels; rounded, and raised to 1 when smaller.
bold bool True for a bold font.

Returns QFont: The resized font.

Declared in src/app/widgets/dials.cpp:34

degrees()

QString degrees(double value)

Formats an angle for a compass readout with three integer digits and one decimal.

Parameters

Name Type Description
value double Angle in degrees, expected in [0, 360).

Returns QString: The angle zero-padded to five characters with a degree sign, such as 045.0°.

Declared in src/app/widgets/dials.cpp:45

File-local variables

kMargin

double kMargin{8.0}

Space between the tick ring and the widget edge, in pixels; the bezel takes 6 of them.

Declared in src/app/widgets/dials.cpp:24

kDegreesToRadians

double kDegreesToRadians{std::numbers::pi / 180.0}

Factor that converts degrees to radians.

Declared in src/app/widgets/dials.cpp:26