|
Wavelength
Privacy-focused, cross-platform, and open-source communication application
|
Handles the rendering of the blob, background grid, and HUD elements. More...
#include <blob_renderer.h>
Public Member Functions | |
| BlobRenderer () | |
| Constructs a BlobRenderer object. Initializes member variables to default states. | |
| void | DrawBackground (QPainter &painter, const QColor &background_color, const QColor &grid_color, int grid_spacing, int width, int height) |
| Draws the background, including a static texture and the dynamic grid. Uses internal caching (grid_buffer_) to avoid redrawing the grid every frame if parameters haven't changed. It also draws a static background texture underneath the grid. | |
| void | DrawCompleteHUD (QPainter &painter, const QPointF &blob_center, double blob_radius, const QColor &hud_color, int width, int height) const |
| Draws the complete static Heads-Up Display (HUD) elements used in the Idle state. Includes corner markers, text labels (ID, radius, amplitude), and a target circle around the blob. | |
| void | ForceHUDInitialization (const QPointF &blob_center, double blob_radius, const QColor &hud_color, int width, int height) |
| Forces the immediate initialization and buffering of the static HUD elements for the Idle state. Calls InitializeIdleState and then renders the HUD into the static_hud_buffer_. | |
| void | InitializeIdleState () |
| Initializes parameters specific to the Idle state HUD display. Generates random ID, calculates amplitude based on time, gets current timestamp. Reset the HUD buffer flags. | |
| void | RenderBlob (QPainter &painter, const std::vector< QPointF > &control_points, const QPointF &blob_center, const BlobConfig::BlobParameters ¶ms) |
| Renders the blob shape itself (filling, border, glow). | |
| void | RenderScene (QPainter &painter, const std::vector< QPointF > &control_points, const QPointF &blob_center, const BlobConfig::BlobParameters ¶ms, const BlobRenderState &render_state, int width, int height, QPixmap &background_cache, QSize &last_background_size, QColor &last_background_color, QColor &last_grid_color, int &last_grid_spacing) |
| Renders the entire scene, including a background, blob, and potentially HUD. Orchestrates the drawing process, using cached background and HUD elements when in the Idle state. Handles the logic for preparing HUD buffers when transitioning to the Idle state. | |
| void | ResetGridBuffer () |
| Resets the internal grid buffer pixmap, forcing it to be redrawn on the next frame. | |
| void | ResetHUD () |
| Resets the HUD buffers and flags, forcing reinitialization on the next transition to Idle state. | |
| void | UpdateGridBuffer (const QColor &background_color, const QColor &grid_color, int grid_spacing, int width, int height) |
| Updates the internal buffer containing the rendered background grid. Called when grid parameters (colors, spacing) or widget size change. | |
| ~BlobRenderer () | |
| Destructor for BlobRenderer. Cleans up allocated resources. | |
Private Member Functions | |
| void | DrawGlowEffect (QPainter &painter, const QPainterPath &blob_path, const QColor &border_color, int glow_radius) |
| Draws the glow effect around the blob path. Uses internal caching (glow_buffer_) to optimize rendering, especially in the Idle state. Delegates the actual drawing to RenderGlowEffect when the buffer needs updating. | |
Static Private Member Functions | |
| static void | DrawBorder (QPainter &painter, const QPainterPath &blob_path, const QColor &border_color, int border_width) |
| Draws the border outline of the blob. Includes a main border and a thinner, lighter inner line for a neon effect. | |
| static void | DrawFilling (QPainter &painter, const QPainterPath &blob_path, const QPointF &blob_center, double blob_radius, const QColor &border_color) |
| Draws the filling inside the blob path using a radial gradient. The gradient fades from a lighter, semi-transparent center towards a darker, transparent edge. | |
| static void | RenderGlowEffect (QPainter &painter, const QPainterPath &blob_path, const QColor &border_color, int glow_radius) |
| Renders the multi-layered glow effect using QPainter drawPath operations with varying pen widths and colors. This static method performs the actual drawing logic used by DrawGlowEffect when updating the cache. | |
Private Attributes | |
| QPixmap | glow_buffer_ |
| Cached pixmap containing the rendered glow effect. Updated based on blob shape, color, and state. | |
| QPixmap | grid_buffer_ |
| Cached pixmap containing the rendered grid lines. Updated when grid parameters or size change. | |
| double | idle_amplitude_ |
| Calculated amplitude value displayed in the Idle state HUD. | |
| QString | idle_blob_id_ |
| Randomly generated ID string displayed in the Idle state HUD. | |
| bool | idle_hud_initialized_ |
| Flag indicating if the static HUD elements for the Idle state have been initialized and buffered. | |
| QString | idle_timestamp_ |
| Timestamp string displayed in the Idle state HUD (potentially dynamic, currently static after init). | |
| bool | is_rendering_active_ |
| Flag indicating if rendering is currently active (used for state transition logic). | |
| BlobConfig::AnimationState | last_animation_state_ |
| Stores the animation state from the previous frame, used for detecting state changes. | |
| QColor | last_background_color_ |
| Stores the background color used for the last grid_buffer_ update. | |
| QColor | last_glow_color_ |
| Stores the border color used for the last glow_buffer_ update. | |
| QPainterPath | last_glow_path_ |
| Stores the blob path used for the last glow_buffer_ update. | |
| int | last_glow_radius_ |
| Stores the glow radius used for the last glow_buffer_ update. | |
| QSize | last_glow_size_ |
| Stores the viewport size used for the last glow_buffer_ update. | |
| QColor | last_grid_color_ |
| Stores the grid color used for the last grid_buffer_ update. | |
| int | last_grid_spacing_ |
| Stores the grid spacing used for the last grid_buffer_ update. | |
| QSize | last_size_ |
| Stores the size used for the last grid_buffer_ update. | |
| PathMarkersManager * | markers_manager_ |
| Markers Manager for drawing animated markers alongside blob border (currently unused). | |
| bool | static_background_initialized_ |
| Flag indicating if static_background_texture_ has been initialized. | |
| QPixmap | static_background_texture_ |
| Cached pixmap containing a static background texture (e.g., gradient, noise). Initialized once. | |
| QPixmap | static_hud_buffer_ |
| Cached pixmap containing the static elements of the HUD rendered during Idle state initialization. | |
Handles the rendering of the blob, background grid, and HUD elements.
This class encapsulates all drawing logic for the Blob animation. It uses QPainter to draw the blob shape (filling, border, glow), the background grid, and informational Heads-Up Display (HUD) elements. It employs caching mechanisms (QPixmap buffers) for the background, grid, glow effect, and HUD to optimize performance, especially when the blob is in the Idle state.
|
inline |
Constructs a BlobRenderer object. Initializes member variables to default states.
|
inline |
Destructor for BlobRenderer. Cleans up allocated resources.
| void BlobRenderer::DrawBackground | ( | QPainter & | painter, |
| const QColor & | background_color, | ||
| const QColor & | grid_color, | ||
| int | grid_spacing, | ||
| int | width, | ||
| int | height ) |
Draws the background, including a static texture and the dynamic grid. Uses internal caching (grid_buffer_) to avoid redrawing the grid every frame if parameters haven't changed. It also draws a static background texture underneath the grid.
| painter | The QPainter to use for drawing. |
| background_color | The desired background color (used for grid buffer update check). |
| grid_color | The desired color for the grid lines. |
| grid_spacing | The desired spacing between grid lines. |
| width | The current width of the rendering area. |
| height | The current height of the rendering area. |
|
staticprivate |
Draws the border outline of the blob. Includes a main border and a thinner, lighter inner line for a neon effect.
| painter | The QPainter to use for drawing. |
| blob_path | The QPainterPath representing the blob's outline. |
| border_color | The color of the main border. |
| border_width | The width of the main border. |
| void BlobRenderer::DrawCompleteHUD | ( | QPainter & | painter, |
| const QPointF & | blob_center, | ||
| double | blob_radius, | ||
| const QColor & | hud_color, | ||
| int | width, | ||
| int | height ) const |
Draws the complete static Heads-Up Display (HUD) elements used in the Idle state. Includes corner markers, text labels (ID, radius, amplitude), and a target circle around the blob.
| painter | The QPainter to use for drawing. |
| blob_center | The center position of the blob. |
| blob_radius | The radius of the blob. |
| hud_color | The color for the HUD elements. |
| width | The width of the rendering area. |
| height | The height of the rendering area. |
|
staticprivate |
Draws the filling inside the blob path using a radial gradient. The gradient fades from a lighter, semi-transparent center towards a darker, transparent edge.
| painter | The QPainter to use for drawing. |
| blob_path | The QPainterPath representing the blob's outline. |
| blob_center | The center point for the radial gradient. |
| blob_radius | The radius for the radial gradient. |
| border_color | The base color used to derive gradient colors. |
|
private |
Draws the glow effect around the blob path. Uses internal caching (glow_buffer_) to optimize rendering, especially in the Idle state. Delegates the actual drawing to RenderGlowEffect when the buffer needs updating.
| painter | The QPainter to use for drawing. |
| blob_path | The QPainterPath representing the blob's outline. |
| border_color | The base color for the glow. |
| glow_radius | The radius/spread of the glow effect. |
| void BlobRenderer::ForceHUDInitialization | ( | const QPointF & | blob_center, |
| double | blob_radius, | ||
| const QColor & | hud_color, | ||
| int | width, | ||
| int | height ) |
Forces the immediate initialization and buffering of the static HUD elements for the Idle state. Calls InitializeIdleState and then renders the HUD into the static_hud_buffer_.
| blob_center | The current center of the blob. |
| blob_radius | The current radius of the blob. |
| hud_color | The color to use for HUD elements. |
| width | The current width of the rendering area. |
| height | The current height of the rendering area. |
| void BlobRenderer::InitializeIdleState | ( | ) |
Initializes parameters specific to the Idle state HUD display. Generates random ID, calculates amplitude based on time, gets current timestamp. Reset the HUD buffer flags.
| void BlobRenderer::RenderBlob | ( | QPainter & | painter, |
| const std::vector< QPointF > & | control_points, | ||
| const QPointF & | blob_center, | ||
| const BlobConfig::BlobParameters & | params ) |
Renders the blob shape itself (filling, border, glow).
| painter | The QPainter to use for drawing. |
| control_points | The current positions of the blob's control points. |
| blob_center | The calculated center of the blob. |
| params | Blob appearance parameters (colors, radius, etc.). |
|
staticprivate |
Renders the multi-layered glow effect using QPainter drawPath operations with varying pen widths and colors. This static method performs the actual drawing logic used by DrawGlowEffect when updating the cache.
| painter | The QPainter to draw onto (typically the glow buffer painter). |
| blob_path | The QPainterPath representing the blob's outline. |
| border_color | The base color for the glow. |
| glow_radius | The radius/spread of the glow effect. |
| void BlobRenderer::RenderScene | ( | QPainter & | painter, |
| const std::vector< QPointF > & | control_points, | ||
| const QPointF & | blob_center, | ||
| const BlobConfig::BlobParameters & | params, | ||
| const BlobRenderState & | render_state, | ||
| int | width, | ||
| int | height, | ||
| QPixmap & | background_cache, | ||
| QSize & | last_background_size, | ||
| QColor & | last_background_color, | ||
| QColor & | last_grid_color, | ||
| int & | last_grid_spacing ) |
Renders the entire scene, including a background, blob, and potentially HUD. Orchestrates the drawing process, using cached background and HUD elements when in the Idle state. Handles the logic for preparing HUD buffers when transitioning to the Idle state.
| painter | The QPainter to use for drawing. |
| control_points | The current positions of the blob's control points. |
| blob_center | The calculated center of the blob. |
| params | Blob appearance parameters. |
| render_state | Current rendering state information (opacity, scale, animation state, etc.). |
| width | The current width of the rendering area. |
| height | The current height of the rendering area. |
| background_cache | Reference to the QPixmap used for caching the background (managed externally, typically by BlobAnimation). |
| last_background_size | Reference to the size used for the last background cache update. |
| last_background_color | Reference to the background color used for the last cache update. |
| last_grid_color | Reference to the grid color used for the last cache update. |
| last_grid_spacing | Reference to the grid spacing used for the last cache update. |
|
inline |
Resets the internal grid buffer pixmap, forcing it to be redrawn on the next frame.
|
inline |
Resets the HUD buffers and flags, forcing reinitialization on the next transition to Idle state.
| void BlobRenderer::UpdateGridBuffer | ( | const QColor & | background_color, |
| const QColor & | grid_color, | ||
| int | grid_spacing, | ||
| int | width, | ||
| int | height ) |
Updates the internal buffer containing the rendered background grid. Called when grid parameters (colors, spacing) or widget size change.
| background_color | The background color to fill behind the grid. |
| grid_color | The color of the grid lines. |
| grid_spacing | The spacing between grid lines in pixels. |
| width | The current width of the rendering area. |
| height | The current height of the rendering area. |
|
private |
Cached pixmap containing the rendered glow effect. Updated based on blob shape, color, and state.
|
private |
Cached pixmap containing the rendered grid lines. Updated when grid parameters or size change.
|
private |
Calculated amplitude value displayed in the Idle state HUD.
|
private |
Randomly generated ID string displayed in the Idle state HUD.
|
private |
Flag indicating if the static HUD elements for the Idle state have been initialized and buffered.
|
private |
Timestamp string displayed in the Idle state HUD (potentially dynamic, currently static after init).
|
private |
Flag indicating if rendering is currently active (used for state transition logic).
|
private |
Stores the animation state from the previous frame, used for detecting state changes.
|
private |
Stores the background color used for the last grid_buffer_ update.
|
private |
Stores the border color used for the last glow_buffer_ update.
|
private |
Stores the blob path used for the last glow_buffer_ update.
|
private |
Stores the glow radius used for the last glow_buffer_ update.
|
private |
Stores the viewport size used for the last glow_buffer_ update.
|
private |
Stores the grid color used for the last grid_buffer_ update.
|
private |
Stores the grid spacing used for the last grid_buffer_ update.
|
private |
Stores the size used for the last grid_buffer_ update.
|
private |
Markers Manager for drawing animated markers alongside blob border (currently unused).
|
private |
Flag indicating if static_background_texture_ has been initialized.
|
private |
Cached pixmap containing a static background texture (e.g., gradient, noise). Initialized once.
|
private |
Cached pixmap containing the static elements of the HUD rendered during Idle state initialization.