Wavelength
Privacy-focused, cross-platform, and open-source communication application
Loading...
Searching...
No Matches
PathMarkersManager Class Reference

Manages the creation, update, and rendering of animated markers along a QPainterPath. More...

#include <path_markers_manager.h>

Collaboration diagram for PathMarkersManager:

Classes

struct  PathMarker
 Structure representing a single animated marker moving along the path. More...
 

Public Member Functions

void DrawMarkers (QPainter &painter, const QPainterPath &blob_path, qint64 current_time)
 Draws all managed markers onto the provided QPainter. Calculates the time delta since the last draw call, updates marker states, determines marker positions on the given path, and calls the appropriate drawing function for each marker type. Initializes markers if the list is empty.
 
const PathMarkerGetMarker (const size_t index) const
 Gets a constant reference to a specific marker by its index. Performs bounds checking via std::vector::at().
 
size_t GetMarkerCount () const
 Gets the current number of active markers.
 
void InitializeMarkers ()
 Initializes or resets the set of markers. Clears existing markers and creates a new random set with varying types, speeds, and appearances. Ensures that the same marker type is not generated twice consecutively.
 
 PathMarkersManager ()
 Constructs a PathMarkersManager. Initializes last update time to 0.
 
void UpdateMarkers (double delta_time)
 Updates the state of all markers based on the elapsed time. Calculates new positions, color phases, wave phases, and quantum states.
 

Static Private Member Functions

static void CalculateTrailPoints (PathMarker &marker, const QPainterPath &blob_path, double position, double path_length)
 Calculates the points needed to draw the trailing effect for an impulse marker. Populates the marker's trailPoints vector.
 
static void DrawImpulseMarker (QPainter &painter, const PathMarker &marker, const QPointF &position, const QColor &marker_color, qint64 current_time)
 Draws a marker of type 0 (Impulse). Renders a cyberpunk-style head element and a fading trail using pre-calculated points.
 
static void DrawQuantumMarker (QPainter &painter, const PathMarker &marker, const QPointF &position, const QColor &marker_color, qint64 current_time)
 Draws a marker of type 2 (Quantum). Renders a central point and several orbiting "quantum copies" whose appearance and behavior change based on the marker's quantumState and quantumStateTime. Includes connecting lines ("entanglement").
 
static void DrawWaveMarker (QPainter &painter, const PathMarker &marker, const QPointF &position, const QColor &marker_color)
 Draws a marker of type 1 (Wave). Renders expanding concentric rings and a subtle distortion effect originating from the marker position.
 
static QColor GetMarkerColor (int marker_type, double color_phase)
 Determines the appropriate color for a marker based on its type and current color phase. Uses HSV color manipulation for smooth transitions.
 

Private Attributes

qint64 last_update_time_
 Timestamp (milliseconds since epoch) of the last call to drawMarkers, used for calculating deltaTime.
 
std::vector< PathMarkermarkers_
 Vector storing all the active PathMarker objects.
 

Detailed Description

Manages the creation, update, and rendering of animated markers along a QPainterPath.

This class creates several types of markers (energy impulses, disturbance waves, quantum effects) that move along a given path (typically the blob's outline). Each marker type has unique visual characteristics and animation behavior. The manager handles marker initialization, position updates based on time, and drawing logic using QPainter.

Constructor & Destructor Documentation

◆ PathMarkersManager()

PathMarkersManager::PathMarkersManager ( )
inline

Constructs a PathMarkersManager. Initializes last update time to 0.

Member Function Documentation

◆ CalculateTrailPoints()

void PathMarkersManager::CalculateTrailPoints ( PathMarker & marker,
const QPainterPath & blob_path,
double position,
double path_length )
staticprivate

Calculates the points needed to draw the trailing effect for an impulse marker. Populates the marker's trailPoints vector.

Parameters
markerReference to the PathMarker (type 0) whose trail points are being calculated (modified).
blob_pathThe path along which the marker moves.
positionThe current absolute position (distance along the path) of the marker head.
path_lengthThe total length of the blobPath.
Here is the caller graph for this function:

◆ DrawImpulseMarker()

void PathMarkersManager::DrawImpulseMarker ( QPainter & painter,
const PathMarker & marker,
const QPointF & position,
const QColor & marker_color,
qint64 current_time )
staticprivate

Draws a marker of type 0 (Impulse). Renders a cyberpunk-style head element and a fading trail using pre-calculated points.

Parameters
painterThe QPainter to use for drawing.
markerThe PathMarker data.
positionThe calculated position (QPointF) on the painter where the marker head should be drawn.
marker_colorThe base color for the marker.
current_timeThe current timestamp for potential time-based effects (e.g., flickering).
Here is the caller graph for this function:

◆ DrawMarkers()

void PathMarkersManager::DrawMarkers ( QPainter & painter,
const QPainterPath & blob_path,
qint64 current_time )

Draws all managed markers onto the provided QPainter. Calculates the time delta since the last draw call, updates marker states, determines marker positions on the given path, and calls the appropriate drawing function for each marker type. Initializes markers if the list is empty.

Parameters
painterThe QPainter to use for drawing.
blob_pathThe QPainterPath along which the markers should be drawn.
current_timeThe current timestamp in milliseconds (e.g., from QDateTime::currentMSecsSinceEpoch()).
Here is the call graph for this function:

◆ DrawQuantumMarker()

void PathMarkersManager::DrawQuantumMarker ( QPainter & painter,
const PathMarker & marker,
const QPointF & position,
const QColor & marker_color,
qint64 current_time )
staticprivate

Draws a marker of type 2 (Quantum). Renders a central point and several orbiting "quantum copies" whose appearance and behavior change based on the marker's quantumState and quantumStateTime. Includes connecting lines ("entanglement").

Parameters
painterThe QPainter to use for drawing.
markerThe PathMarker data (uses quantumState, quantumStateTime, etc.).
positionThe calculated position (QPointF) on the painter for the central point.
marker_colorThe base color for the marker.
current_timeThe current timestamp for time-based animation effects.
Here is the caller graph for this function:

◆ DrawWaveMarker()

void PathMarkersManager::DrawWaveMarker ( QPainter & painter,
const PathMarker & marker,
const QPointF & position,
const QColor & marker_color )
staticprivate

Draws a marker of type 1 (Wave). Renders expanding concentric rings and a subtle distortion effect originating from the marker position.

Parameters
painterThe QPainter to use for drawing.
markerThe PathMarker data (uses wavePhase).
positionThe calculated position (QPointF) on the painter, representing the wave's origin.
marker_colorThe base color for the marker.
Here is the caller graph for this function:

◆ GetMarker()

const PathMarker & PathMarkersManager::GetMarker ( const size_t index) const
inline

Gets a constant reference to a specific marker by its index. Performs bounds checking via std::vector::at().

Parameters
indexThe index of the desired marker.
Returns
A constant reference to the PathMarker struct.
Exceptions
out_of_rangeif the index is invalid.

◆ GetMarkerColor()

QColor PathMarkersManager::GetMarkerColor ( int marker_type,
double color_phase )
staticprivate

Determines the appropriate color for a marker based on its type and current color phase. Uses HSV color manipulation for smooth transitions.

Parameters
marker_typeThe type of the marker (0, 1, or 2).
color_phaseThe current color phase (0.0 to 1.0).
Returns
The calculated QColor for the marker.
Here is the caller graph for this function:

◆ GetMarkerCount()

size_t PathMarkersManager::GetMarkerCount ( ) const
inline

Gets the current number of active markers.

Returns
The number of markers in the m_markers vector.

◆ InitializeMarkers()

void PathMarkersManager::InitializeMarkers ( )

Initializes or resets the set of markers. Clears existing markers and creates a new random set with varying types, speeds, and appearances. Ensures that the same marker type is not generated twice consecutively.

Here is the caller graph for this function:

◆ UpdateMarkers()

void PathMarkersManager::UpdateMarkers ( double delta_time)

Updates the state of all markers based on the elapsed time. Calculates new positions, color phases, wave phases, and quantum states.

Parameters
delta_timeTime elapsed since the last update in seconds.
Here is the caller graph for this function:

Member Data Documentation

◆ last_update_time_

qint64 PathMarkersManager::last_update_time_
private

Timestamp (milliseconds since epoch) of the last call to drawMarkers, used for calculating deltaTime.

◆ markers_

std::vector<PathMarker> PathMarkersManager::markers_
private

Vector storing all the active PathMarker objects.


The documentation for this class was generated from the following files: