wPlot2D version: 0.1.0
A lightweight C++ library for clear and customizable 2D scientific plots.
Loading...
Searching...
No Matches
wLineEntity.hpp
Go to the documentation of this file.
1/*
2+---------------------------------------------------------------------------------------------------------------------------------------------------+
3Created by Wilfried Koch.
4Copyright @ 2025 Wilfried Koch. All rights reserved.
5+---------------------------------------------------------------------------------------------------------------------------------------------------+
6*/
7
8#ifndef W_LINE_ENTITY_HPP
9#define W_LINE_ENTITY_HPP
10
13
14#pragma GCC diagnostic push
15#pragma GCC diagnostic ignored "-Wfloat-equal"
16#pragma GCC diagnostic ignored "-Wswitch-default"
17#include <SFML/Graphics.hpp>
18#pragma GCC diagnostic pop
19
20namespace wPlot2D
21{
22
43 {
44 public:
54 LineEntity( const sf::Vector2f& origin, const sf::Vector2f& scale, const sf::Vector2f& start, const sf::Vector2f& end,
55 bool withArrow = false );
56
60 virtual ~LineEntity( ) = default;
61
66 void setColor( sf::Color color );
67
72 void setThickness( float thickness );
73
78 [[nodiscard]] float getThickness( ) const;
79
85
90 void setDashLength( float dashLength );
91
96 void setGapLength( float gapLength );
97
102 [[nodiscard]] sf::Vector2f getStartPoint( ) const;
103
108 [[nodiscard]] sf::Vector2f getEndPoint( ) const;
109
114 [[nodiscard]] bool hasArrow( ) const;
115
120 [[nodiscard]] float getArrowSize( ) const;
121
126 void setArrowSize( float arrowSize );
127
132 void render( sf::RenderWindow& window );
133
134 private:
135 sf::Vector2f mStart;
136 sf::Vector2f mEnd;
137 bool mWithArrow;
138 sf::ConvexShape mArrowHead;
139 float mArrowSize;
140
152 void initArrowHead( const sf::Vector2f& lineEnd, const sf::Vector2f& dir, float arrowSize, sf::Color color );
153 };
154
155}//End of namespace wPlot2D
156
157#endif
Represents an entity in the ECS (Entity-Component System) architecture.
Definition wEntity.hpp:60
LineStyle
Available styles for line rendering.
Definition wLineStyleComponent.hpp:35
void setDashLength(float dashLength)
Sets the dash length for dashed lines.
Definition wLineEntity.cpp:62
float getThickness() const
Returns the current thickness of the line.
Definition wLineEntity.cpp:42
void setThickness(float thickness)
Sets the thickness of the line.
Definition wLineEntity.cpp:52
virtual ~LineEntity()=default
Virtual destructor.
void setArrowSize(float arrowSize)
Sets the arrowhead size factor.
Definition wLineEntity.cpp:92
bool hasArrow() const
Checks if the line has an arrowhead.
Definition wLineEntity.cpp:82
sf::Vector2f getStartPoint() const
Returns the starting point of the line.
Definition wLineEntity.cpp:72
void render(sf::RenderWindow &window)
Renders the line (and optional arrowhead).
Definition wLineEntity.cpp:103
void setGapLength(float gapLength)
Sets the gap length between dashes or dots.
Definition wLineEntity.cpp:67
sf::Vector2f getEndPoint() const
Returns the ending point of the line.
Definition wLineEntity.cpp:77
float getArrowSize() const
Returns the arrowhead size factor.
Definition wLineEntity.cpp:87
void setColor(sf::Color color)
Sets the color of the line and arrowhead.
Definition wLineEntity.cpp:47
LineEntity(const sf::Vector2f &origin, const sf::Vector2f &scale, const sf::Vector2f &start, const sf::Vector2f &end, bool withArrow=false)
Construct a line entity between two points.
Definition wLineEntity.cpp:23
void setLineStyle(wEngine::LineStyleComponent::LineStyle style)
Sets the visual style of the line.
Definition wLineEntity.cpp:57
Definition wAxisEntity.cpp:17