InstrumentTile¶
class nmeasim::app::InstrumentTile · Applications
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.
Inherits QFrame
Declared in src/app/widgets/instrument_tile.hpp (line 24)
An active override draws the tile with a warning-coloured border.
The tile only displays and edits numbers; it knows nothing of the simulation. DashboardWidget maps its override_changed signal to a core::simulation::Parameter. The object name instrument_tile and the dynamic property overridden select the style-sheet rules of theme::Theme; the caption, readout and unit labels are named tile_title, tile_value and tile_unit. Every child widget is owned by the tile.
Summary¶
Public member functions
| Name | Description |
|---|---|
InstrumentTile() |
Creates a display-only tile that reads -- until a value is set. |
set_value() |
Shows a numeric value with the given number of decimals. |
set_text() |
Shows arbitrary text, for values such as positions or times. |
text() |
Returns the text of the readout. |
overridden() |
Returns whether the tile is drawn as overridden. |
enable_override() |
Adds the override control. |
override_active() |
Returns whether the override check box is ticked. |
override_value() |
Returns the value of the override spin box. |
set_override() |
Sets the control without emitting override_changed. |
set_override_range() |
Changes the range of the override spin box, for example to the rudder limit of a profile. |
set_override_enabled() |
Enables or disables the override control, for example the rudder outside steering mode. |
Signals
| Name | Description |
|---|---|
override_changed() |
Emitted when the operator ticks or unticks the override, or changes the spin box while the override is active. |
Private member functions
| Name | Description |
|---|---|
set_readout_scale() |
Switches the readout font to scale times the label's original point size, unless that scale is already in use. |
mark_overridden() |
Sets the overridden property and re-polishes the tile so that the border follows it. |
Private data members
| Name | Description |
|---|---|
value_label_ |
Large digital readout, owned by the tile. |
unit_label_ |
Unit next to the readout, owned by the tile. |
override_check_ |
Override check box, owned by the tile; null until enable_override. |
override_spin_ |
Override value, owned by the tile; null until enable_override. |
suppress_signals_ |
True inside set_override, so that programmatic changes emit no override_changed. |
base_point_size_ |
Point size of the readout label's default font, the base of the readout scales. |
readout_scale_ |
Scale of the current readout font; 0 until the first set_value or set_text. |
Public member functions¶
InstrumentTile()¶
InstrumentTile(const QString& title, const QString& unit, QWidget* parent = nullptr)
Creates a display-only tile that reads -- until a value is set.
Parameters
| Name | Type | Description |
|---|---|---|
title |
const QString& |
Caption, shown in bold capitals. |
unit |
const QString& |
Unit shown to the right of the readout, such as kn; empty for none. |
parent |
QWidget* |
Parent widget, which owns the tile; may be null, in which case the caller owns it. |
Declared in src/app/widgets/instrument_tile.hpp:34 · defined in src/app/widgets/instrument_tile.cpp:40
set_value()¶
void set_value(double value, int decimals)
Shows a numeric value with the given number of decimals.
Numeric readouts use a larger font than text readouts. The override control is not touched, so an overridden tile shows the simulated value while keeping its control value.
Parameters
| Name | Type | Description |
|---|---|---|
value |
double |
Value in the tile's unit. |
decimals |
int |
Number of digits after the decimal point. |
Declared in src/app/widgets/instrument_tile.hpp:44 · defined in src/app/widgets/instrument_tile.cpp:71
set_text()¶
void set_text(const QString& text)
Shows arbitrary text, for values such as positions or times.
Parameters
| Name | Type | Description |
|---|---|---|
text |
const QString& |
Text to show; may span several lines. |
Declared in src/app/widgets/instrument_tile.hpp:48 · defined in src/app/widgets/instrument_tile.cpp:76
text()¶
QString text() const
Returns the text of the readout.
Returns QString: The readout as shown, -- before the first set_value or set_text.
Declared in src/app/widgets/instrument_tile.hpp:52
overridden()¶
bool overridden() const
Returns whether the tile is drawn as overridden.
Returns bool: True while the override is active, which the style sheet shows as an amber border.
Declared in src/app/widgets/instrument_tile.hpp:57
enable_override()¶
void enable_override(double minimum, double maximum, double step, int decimals)
Adds the override control.
Until this is called the tile is display-only.
The control is an Override check box and a spin box, which is enabled only while the box is ticked and applies a typed value when editing finishes rather than on every keystroke. A second call does nothing.
Parameters
| Name | Type | Description |
|---|---|---|
minimum |
double |
Smallest value the spin box accepts, in the tile's unit. |
maximum |
double |
Largest value the spin box accepts, in the tile's unit. |
step |
double |
Change per arrow click or key press, in the tile's unit. |
decimals |
int |
Number of decimals the spin box shows and accepts. |
Declared in src/app/widgets/instrument_tile.hpp:69 · defined in src/app/widgets/instrument_tile.cpp:99
override_active()¶
bool override_active() const
Returns whether the override check box is ticked.
Returns bool: True while the override is active; false for a display-only tile.
Declared in src/app/widgets/instrument_tile.hpp:73 · defined in src/app/widgets/instrument_tile.cpp:131
override_value()¶
double override_value() const
Returns the value of the override spin box.
Returns double: The spin box value in the tile's unit, also when the override is not active; 0 for a display-only tile.
Declared in src/app/widgets/instrument_tile.hpp:78 · defined in src/app/widgets/instrument_tile.cpp:135
set_override()¶
void set_override(bool active, double value)
Sets the control without emitting override_changed.
Used to reflect overrides set elsewhere, such as keyboard nudges. The value is clamped to the range of the spin box. The spin box stays disabled while the control is disabled (see set_override_enabled). Does nothing on a display-only tile.
Parameters
| Name | Type | Description |
|---|---|---|
active |
bool |
True to tick the check box and draw the tile as overridden. |
value |
double |
Value for the spin box, in the tile's unit. |
Declared in src/app/widgets/instrument_tile.hpp:87 · defined in src/app/widgets/instrument_tile.cpp:139
set_override_range()¶
void set_override_range(double minimum, double maximum)
Changes the range of the override spin box, for example to the rudder limit of a profile.
A value outside the new range is clamped into it without emitting override_changed. Does nothing on a display-only tile.
Parameters
| Name | Type | Description |
|---|---|---|
minimum |
double |
Smallest value the spin box accepts, in the tile's unit. |
maximum |
double |
Largest value the spin box accepts, in the tile's unit; not below minimum. |
Declared in src/app/widgets/instrument_tile.hpp:97 · defined in src/app/widgets/instrument_tile.cpp:150
set_override_enabled()¶
void set_override_enabled(bool enabled)
Enables or disables the override control, for example the rudder outside steering mode.
Does nothing on a display-only tile. The spin box is enabled only when enabled is true and the check box is ticked.
Parameters
| Name | Type | Description |
|---|---|---|
enabled |
bool |
False to grey out the check box and the spin box. |
Declared in src/app/widgets/instrument_tile.hpp:105 · defined in src/app/widgets/instrument_tile.cpp:159
Signals¶
override_changed()¶
void override_changed(bool active, double value)
Emitted when the operator ticks or unticks the override, or changes the spin box while the override is active.
Emitted synchronously from the control's own signal; not emitted from set_override, nor for spin box changes while the override is inactive.
Parameters
| Name | Type | Description |
|---|---|---|
active |
bool |
True when the override is active, false when it was released. |
value |
double |
Value of the spin box, in the tile's unit. |
Declared in src/app/widgets/instrument_tile.hpp:116
Private member functions¶
set_readout_scale()¶
void set_readout_scale(double scale)
Switches the readout font to scale times the label's original point size, unless that scale is already in use.
Parameters
| Name | Type | Description |
|---|---|---|
scale |
double |
Factor applied to base_point_size_. |
Declared in src/app/widgets/instrument_tile.hpp:123 · defined in src/app/widgets/instrument_tile.cpp:81
mark_overridden()¶
void mark_overridden(bool overridden)
Sets the overridden property and re-polishes the tile so that the border follows it.
Parameters
| Name | Type | Description |
|---|---|---|
overridden |
bool |
New value of the property; nothing happens when it is unchanged. |
Declared in src/app/widgets/instrument_tile.hpp:127 · defined in src/app/widgets/instrument_tile.cpp:89
Private data members¶
value_label_¶
QLabel* value_label_
Large digital readout, owned by the tile.
Declared in src/app/widgets/instrument_tile.hpp:130
unit_label_¶
QLabel* unit_label_
Unit next to the readout, owned by the tile.
Declared in src/app/widgets/instrument_tile.hpp:132
override_check_¶
QCheckBox* override_check_{nullptr}
Override check box, owned by the tile; null until enable_override.
Declared in src/app/widgets/instrument_tile.hpp:134
override_spin_¶
QDoubleSpinBox* override_spin_{nullptr}
Override value, owned by the tile; null until enable_override.
Declared in src/app/widgets/instrument_tile.hpp:136
suppress_signals_¶
bool suppress_signals_{false}
True inside set_override, so that programmatic changes emit no override_changed.
Declared in src/app/widgets/instrument_tile.hpp:138
base_point_size_¶
double base_point_size_{10.0}
Point size of the readout label's default font, the base of the readout scales.
Declared in src/app/widgets/instrument_tile.hpp:140
readout_scale_¶
double readout_scale_{0.0}
Scale of the current readout font; 0 until the first set_value or set_text.
Declared in src/app/widgets/instrument_tile.hpp:142