![]() |
RumPi Linux Client 1.0
A wxWidgets desktop dashboard that visualizes a RumPi robot's live sensor data as a condition-reactive scene
|
The Home tab's stylized, condition-reactive backdrop. More...
#include <HomeScenePanel.h>
Public Member Functions | |
| HomeScenePanel (wxWindow *parent) | |
| Builds the scene panel: loads the tunable settings from ClientConfig, seeds and loads the day/night SVG art (falling back to embedded defaults), binds the paint/size/timer events, and starts the animation timer. More... | |
| void | Update (const RumPi::SelectedSensorReadings &readings) |
| Stores the latest sensor snapshot (on the UI thread) and schedules a repaint so the overlays reflect it. More... | |
Protected Member Functions | |
| double | LocalTimeInHours () const |
| Gets the current local time as a fractional number of hours (e.g. More... | |
| double | NightAmount () const |
| Computes how "night" it is now, from 0.0 (full day) to 1.0 (full night), using a sun-elevation proxy that peaks at noon. More... | |
| wxColour | Co2DotColour (float co2) const |
| Picks the status-dot colour for a CO2 reading, using the configured fresh/elevated thresholds and (accessibility- overridable) colours. More... | |
| wxColour | AirQualityDotColour (RumPi::E_AirQualityLevel airQualityLevel) const |
| Picks the status-dot colour for an air-quality level, collapsing the six levels onto the same good/warning/bad palette as the CO2 dot so there is a single palette to retune for accessibility. More... | |
| wxBitmapBundle | LoadSceneBundle (const wxString &folder, const wxString &baseName, const char *embeddedSvg) const |
| Loads a scene image bundle, preferring a user-supplied file (svg, then raster) in the images folder and falling back to the embedded SVG art. More... | |
| void | CreateDefaultScenesIfMissing (const wxString &folder) const |
| Seeds the images folder with editable copies of the default day/night SVG art, but only when the folder does not exist yet, so a user's own art is never clobbered. More... | |
| void | EnsureBaseCache (int width, int height, int blendBucket) |
| Rebuilds the cached day/night-crossfaded base image, but only when the draw size or the bucketed blend has changed, so the SVG art is not re-rasterized every frame. More... | |
| void | DrawCelestialBody (wxGraphicsContext *graphicsContext, int width, int height) |
| Draws the procedural sun (day) or moon (night) arcing across the sky by real local time, clipped to the sky so it slips behind the horizon as it rises and sets. More... | |
| void | DrawAtmosphere (wxGraphicsContext *graphicsContext, int width, int height) |
| Draws the reading-driven atmospheric overlays: dawn/dusk glow, temperature tint, humidity clouds, air-quality haze, humidity mist, and wind streaks, each mapped from its reading through a response curve. More... | |
| void | DrawStreetlights (wxGraphicsContext *graphicsContext, int width, int height) |
| Draws the default scene's lamp posts, lit by the TSL2591 light level (brighter the darker it gets) and guarded on a present light sensor so they only appear when there is a real reading. More... | |
| void | DrawPills (wxGraphicsContext *graphicsContext, int width, int height) |
| Draws the glanceable info pills: the location and clock along the top, and a bottom strip of reading pills (temperature, humidity, air quality, CO2, wind) with colour-coded status dots on the air-quality and CO2 pills. More... | |
| void | OnPaint (wxPaintEvent &event) |
| Paint handler: cover-scales and blits the cached base, then composites the celestial body, atmosphere, streetlights, and info pills into a reused off-screen buffer and blits it once (flicker-free). More... | |
| void | RenderScene (wxPaintDC &drawContext) |
| Composites one frame (base art, celestial body, atmosphere, streetlights, pills) into the off-screen buffer and blits it. More... | |
| void | OnSize (wxSizeEvent &event) |
| Size handler: schedules a repaint so the scene re-scales to the new panel size. More... | |
| void | OnTimer (wxTimerEvent &event) |
| Timer handler: advances the wind and cloud animation phases (a baseline drift plus an amount proportional to wind speed) and schedules a repaint. More... | |
Protected Attributes | |
| double | mySceneAspect |
| The scene's aspect ratio. More... | |
| wxBitmapBundle | myDayScene |
| Day base art (SVG bundle). More... | |
| wxBitmapBundle | myNightScene |
| Night base art (SVG bundle). More... | |
| RumPi::SelectedSensorReadings | myReadings |
| wxBitmap | myBaseCache |
| Cached crossfaded base image. More... | |
| int | myBaseCacheWidth |
| Width the base cache was built at. More... | |
| int | myBaseCacheHeight |
| Height the base cache was built at. More... | |
| int | myBaseCacheBlendBucket |
| Bucketed day/night blend the base cache was built at. More... | |
| wxBitmap | myFrameBuffer |
| double | myWindPhase |
| Current wind animation phase. More... | |
| double | myCloudPhase |
| Current cloud animation phase. More... | |
| wxTimer | myAnimationTimer |
| Timer that advances the animation phases between snapshots. More... | |
| wxString | myLocationName |
| Configured location name. More... | |
| double | myCo2FreshMax |
| Upper CO2 bound for the "fresh" band. More... | |
| double | myCo2ElevatedMax |
| Upper CO2 bound for the "elevated" band. More... | |
| double | myTempWarmAbove |
| Temperature above which the tint reads "warm". More... | |
| double | myTempCoolBelow |
| Temperature below which the tint reads "cool". More... | |
| double | myDuskGlowOpacity |
| Maximum dusk-glow overlay opacity. More... | |
| double | myTemperatureTintOpacity |
| Maximum temperature-tint overlay opacity. More... | |
| double | myCloudOpacity |
| Maximum cloud overlay opacity. More... | |
| double | myHazeOpacity |
| Maximum haze overlay opacity. More... | |
| double | myMistOpacity |
| Maximum mist overlay opacity. More... | |
| double | myWindOpacity |
| Maximum wind overlay opacity. More... | |
| wxColour | myCo2FreshColour |
| Indicator colour for the "fresh" CO2 band. More... | |
| wxColour | myCo2ElevatedColour |
| Indicator colour for the "elevated" CO2 band. More... | |
| wxColour | myCo2HighColour |
| Indicator colour for the "high" CO2 band. More... | |
Static Protected Attributes | |
| static constexpr double | DESIGN_WIDTH = 1920.0 |
| The SVG authoring width overlays are positioned against. More... | |
The Home tab's stylized, condition-reactive backdrop.
It draws a day/night base scene (loaded once as scalable SVG art, crossfaded by local time and cached so the SVG is not re-rasterized every frame) and paints procedural overlays on top - clouds, haze, temperature tint, wind streaks, mist - plus a set of glanceable info pills. The overlays are driven by the latest SelectedSensorReadings; a wxTimer advances the motion (drifting wind and clouds) between snapshots. Tunable constants (location, thresholds, overlay opacities, frame rate) come from ClientConfig at construction.
| HomeScenePanel::HomeScenePanel | ( | wxWindow * | parent | ) |
Builds the scene panel: loads the tunable settings from ClientConfig, seeds and loads the day/night SVG art (falling back to embedded defaults), binds the paint/size/timer events, and starts the animation timer.
| [in] | parent | The parent window. |
|
protected |
Picks the status-dot colour for an air-quality level, collapsing the six levels onto the same good/warning/bad palette as the CO2 dot so there is a single palette to retune for accessibility.
| [in] | airQualityLevel | The air-quality level. |
|
protected |
Picks the status-dot colour for a CO2 reading, using the configured fresh/elevated thresholds and (accessibility- overridable) colours.
| [in] | co2 | The CO2 reading, in ppm. |
|
protected |
Seeds the images folder with editable copies of the default day/night SVG art, but only when the folder does not exist yet, so a user's own art is never clobbered.
| [in] | folder | The images folder to seed. |
|
protected |
Draws the reading-driven atmospheric overlays: dawn/dusk glow, temperature tint, humidity clouds, air-quality haze, humidity mist, and wind streaks, each mapped from its reading through a response curve.
| [in] | graphicsContext | The graphics context to draw into. |
| [in] | width | The draw width, in pixels. |
| [in] | height | The draw height, in pixels. |
|
protected |
Draws the procedural sun (day) or moon (night) arcing across the sky by real local time, clipped to the sky so it slips behind the horizon as it rises and sets.
| [in] | graphicsContext | The graphics context to draw into. |
| [in] | width | The draw width, in pixels. |
| [in] | height | The draw height, in pixels. |
|
protected |
Draws the glanceable info pills: the location and clock along the top, and a bottom strip of reading pills (temperature, humidity, air quality, CO2, wind) with colour-coded status dots on the air-quality and CO2 pills.
| [in] | graphicsContext | The graphics context to draw into. |
| [in] | width | The draw width, in pixels. |
| [in] | height | The draw height, in pixels. |
|
protected |
Draws the default scene's lamp posts, lit by the TSL2591 light level (brighter the darker it gets) and guarded on a present light sensor so they only appear when there is a real reading.
| [in] | graphicsContext | The graphics context to draw into. |
| [in] | width | The draw width, in pixels. |
| [in] | height | The draw height, in pixels. |
|
protected |
Rebuilds the cached day/night-crossfaded base image, but only when the draw size or the bucketed blend has changed, so the SVG art is not re-rasterized every frame.
| [in] | width | The draw width to build the cache at. |
| [in] | height | The draw height to build the cache at. |
| [in] | blendBucket | The bucketed night amount (0 - 100) to crossfade at. |
|
protected |
Loads a scene image bundle, preferring a user-supplied file (svg, then raster) in the images folder and falling back to the embedded SVG art.
| [in] | folder | The images folder to look in. |
| [in] | baseName | The base file name (without extension) to look for. |
| [in] | embeddedSvg | The embedded SVG to fall back to. |
|
protected |
Gets the current local time as a fractional number of hours (e.g.
15.5 for 15:30).
|
protected |
Computes how "night" it is now, from 0.0 (full day) to 1.0 (full night), using a sun-elevation proxy that peaks at noon.
|
protected |
Paint handler: cover-scales and blits the cached base, then composites the celestial body, atmosphere, streetlights, and info pills into a reused off-screen buffer and blits it once (flicker-free).
| [in] | event | The paint event. |
|
protected |
Size handler: schedules a repaint so the scene re-scales to the new panel size.
| [in] | event | The size event. |
|
protected |
Timer handler: advances the wind and cloud animation phases (a baseline drift plus an amount proportional to wind speed) and schedules a repaint.
| [in] | event | The timer event. |
|
protected |
Composites one frame (base art, celestial body, atmosphere, streetlights, pills) into the off-screen buffer and blits it.
Split out of OnPaint so the paint handler can wrap it in a try/catch - a bad_alloc while compositing full-screen on a low-RAM Pi must not escape the wx paint handler through GTK and terminate the app.
| [in] | drawContext | The paint DC the finished frame is blitted to. |
| void HomeScenePanel::Update | ( | const RumPi::SelectedSensorReadings & | readings | ) |
Stores the latest sensor snapshot (on the UI thread) and schedules a repaint so the overlays reflect it.
| [in] | readings | The latest curated sensor readings. |
|
staticconstexprprotected |
The SVG authoring width overlays are positioned against.
|
protected |
Timer that advances the animation phases between snapshots.
|
protected |
Cached crossfaded base image.
|
protected |
Bucketed day/night blend the base cache was built at.
|
protected |
Height the base cache was built at.
|
protected |
Width the base cache was built at.
|
protected |
Maximum cloud overlay opacity.
|
protected |
Current cloud animation phase.
|
protected |
Indicator colour for the "elevated" CO2 band.
|
protected |
Upper CO2 bound for the "elevated" band.
|
protected |
Indicator colour for the "fresh" CO2 band.
|
protected |
Upper CO2 bound for the "fresh" band.
|
protected |
Indicator colour for the "high" CO2 band.
|
protected |
Day base art (SVG bundle).
|
protected |
Maximum dusk-glow overlay opacity.
|
protected |
|
protected |
Maximum haze overlay opacity.
|
protected |
Configured location name.
|
protected |
Maximum mist overlay opacity.
|
protected |
Night base art (SVG bundle).
|
protected |
|
protected |
The scene's aspect ratio.
|
protected |
Temperature below which the tint reads "cool".
|
protected |
Maximum temperature-tint overlay opacity.
|
protected |
Temperature above which the tint reads "warm".
|
protected |
Maximum wind overlay opacity.
|
protected |
Current wind animation phase.