wPlot2D version: 0.1.0
A lightweight C++ library for clear and customizable 2D scientific plots.
Loading...
Searching...
No Matches
wPlot2D::DataPlotEntity Class Reference

Entity for plotting raw data points as a connected polyline. More...

#include <wDataPlotEntity.hpp>

Inheritance diagram for wPlot2D::DataPlotEntity:
Inheritance graph

Public Member Functions

 DataPlotEntity (const sf::Vector2f origin, const sf::Vector2f scale, const std::vector< sf::Vector2f > &dataPoints)
 Constructs a DataPlotEntity with given origin, scale, and raw data points.
virtual ~DataPlotEntity ()=default
 Virtual destructor.
sf::Color getColor () const
 Get the current line color.
float getThickness ()
 Get the line thickness in pixels.
wEngine::LineStyleComponent::LineStyle getLineStyle ()
 Get the current line style.
float getDashLength ()
 Get the dash length for dashed lines.
float getGapLength ()
 Get the gap length for dashed/dotted lines.
void setColor (sf::Color color)
 Sets the color of the plotted line.
void setThickness (float thickness)
 Sets the line thickness in pixels.
void setLineStyle (wEngine::LineStyleComponent::LineStyle style)
 Sets the line style (Solid, Dashed, or Dotted).
void setDashLength (float dashLength)
 Sets the dash length for dashed lines.
void setGapLength (float gapLength)
 Sets the gap length between dashes or dots.
void drawDataPlot (sf::RenderWindow &window)
 Draws the connected data points to the window.
Public Member Functions inherited from wEngine::Entity
 Entity ()
virtual ~Entity ()
unsigned int getEntityID () const
 Returns the unique ID associated with this entity.
void clearComponents ()
 Removes all components currently attached to the entity.
template<typename T, typename... Args>
std::shared_ptr< T > addComponent (Args &&... args)
 Adds a new component of type T to the entity.
template<typename T>
void removeComponent ()
 Removes the component of type T from the entity.
template<typename T>
bool hasComponent () const noexcept
 Checks whether the entity has a component of type T.
template<typename T>
std::shared_ptr< T > getComponent () const
 Retrieves the component of type T attached to the entity.
template<typename T>
std::shared_ptr< T > requireComponent (const std::string &context="") const
 Retrieves the component of type T and throws if it's missing.
template<typename Interface>
std::shared_ptr< Interface > getInterfaceComponent () const
 Returns the first component that implements the specified interface.

Additional Inherited Members

Static Public Member Functions inherited from wEngine::Entity
static void resetEntityIDCounter ()
 Resets the global entity ID counter to zero.

Detailed Description

Entity for plotting raw data points as a connected polyline.

Stores a vector of raw (x,y) points and draws straight line segments between them. Each segment is rendered using the current line style (Solid, Dashed, Dotted), with configurable color, thickness, dash length, and gap length.

Note
Unlike FunctionEntity, this class does not evaluate a function — it directly uses the provided data points. The points are still transformed by the entity's origin and scale before rendering.
Author
Wilfried Koch

Constructor & Destructor Documentation

◆ DataPlotEntity()

wPlot2D::DataPlotEntity::DataPlotEntity ( const sf::Vector2f origin,
const sf::Vector2f scale,
const std::vector< sf::Vector2f > & dataPoints )

Constructs a DataPlotEntity with given origin, scale, and raw data points.

Parameters
originOrigin of the plot in window coordinates.
scaleScaling factors applied to x and y values.
dataPointsVector of raw (x,y) points to plot.

◆ ~DataPlotEntity()

virtual wPlot2D::DataPlotEntity::~DataPlotEntity ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ getColor()

sf::Color wPlot2D::DataPlotEntity::getColor ( ) const
nodiscard

Get the current line color.

Returns
The SFML color used for rendering the polyline.

◆ getThickness()

float wPlot2D::DataPlotEntity::getThickness ( )
nodiscard

Get the line thickness in pixels.

Returns
Current thickness value.

◆ getLineStyle()

wEngine::LineStyleComponent::LineStyle wPlot2D::DataPlotEntity::getLineStyle ( )
nodiscard

Get the current line style.

Returns
Solid, Dashed, or Dotted.

◆ getDashLength()

float wPlot2D::DataPlotEntity::getDashLength ( )
nodiscard

Get the dash length for dashed lines.

Returns
Dash length in pixels.

◆ getGapLength()

float wPlot2D::DataPlotEntity::getGapLength ( )
nodiscard

Get the gap length for dashed/dotted lines.

Returns
Gap length in pixels.

◆ setColor()

void wPlot2D::DataPlotEntity::setColor ( sf::Color color)

Sets the color of the plotted line.

Parameters
colorNew SFML color.

◆ setThickness()

void wPlot2D::DataPlotEntity::setThickness ( float thickness)

Sets the line thickness in pixels.

Parameters
thicknessLine width.

◆ setLineStyle()

void wPlot2D::DataPlotEntity::setLineStyle ( wEngine::LineStyleComponent::LineStyle style)

Sets the line style (Solid, Dashed, or Dotted).

Parameters
styleNew line style.

◆ setDashLength()

void wPlot2D::DataPlotEntity::setDashLength ( float dashLength)

Sets the dash length for dashed lines.

Parameters
dashLengthLength of each dash in pixels.

◆ setGapLength()

void wPlot2D::DataPlotEntity::setGapLength ( float gapLength)

Sets the gap length between dashes or dots.

Parameters
gapLengthLength of the gap in pixels.

◆ drawDataPlot()

void wPlot2D::DataPlotEntity::drawDataPlot ( sf::RenderWindow & window)

Draws the connected data points to the window.

The data points are transformed by scale and origin, then connected with styled line segments using LineDrawer::drawLine.

Parameters
windowTarget SFML render window.

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