KiCad PCB EDA Suite
Loading...
Searching...
No Matches
LINE_ENDING Class Reference

Decorative shape (arrowhead, circle, square) at the start or end of a graphic line, arc, or bezier. More...

#include <line_ending.h>

Public Member Functions

 LINE_ENDING ()
 
 LINE_ENDING (LINE_ENDING_STYLE aStyle, int aLength=0, int aWidth=0, int aStrokeWidth=0)
 
LINE_ENDING_STYLE GetStyle () const
 
void SetStyle (LINE_ENDING_STYLE aStyle)
 
int GetLength () const
 Along-line size. 0 = auto.
 
void SetLength (int aLength)
 
int GetWidth () const
 Perpendicular size. 0 = auto.
 
void SetWidth (int aWidth)
 
void SetUniformSize (int aSize)
 
int GetStrokeWidth () const
 Outline stroke width.
 
void SetStrokeWidth (int aWidth)
 
const STROKE_PARAMSGetStroke () const
 
void SetStroke (const STROKE_PARAMS &aStroke)
 
VECTOR2I GetEffectiveSize (int aLineWidth) const
 Return the rendered size per axis, applying auto-sizing when length or width is 0.
 
int GetShortenDepth (int aLineWidth) const
 Return how far the line should be shortened at this ending.
 
int GetCurveOrientationDepth (int aLineWidth) const
 Return how far along a curved body to look when orienting this ending.
 
void GetShapes (const VECTOR2I &aPoint, const EDA_ANGLE &aTangent, int aLineWidth, std::vector< VECTOR2I > &aPolygon) const
 Generate ending geometry as polygon vertices at the given point and direction.
 
bool operator== (const LINE_ENDING &aOther) const
 
bool operator!= (const LINE_ENDING &aOther) const
 
void Draw (KIGFX::GAL &aGal, const VECTOR2I &aPoint, const EDA_ANGLE &aTangent, double aLineWidth, const KIGFX::COLOR4D &aColor) const
 
void Plot (PLOTTER *aPlotter, const VECTOR2I &aPoint, const EDA_ANGLE &aTangent, int aLineWidth, void *aData=nullptr) const
 
void Format (OUTPUTFORMATTER *aOut, const EDA_IU_SCALE &aIuScale, const char *aToken) const
 

Static Public Member Functions

static wxString StyleToToken (LINE_ENDING_STYLE aStyle)
 
static LINE_ENDING_STYLE TokenToStyle (const wxString &aToken)
 
static int StyleToChoiceIndex (LINE_ENDING_STYLE aStyle)
 Return the dropdown index for the given style, or 0 (NONE) if not found.
 

Static Public Attributes

static constexpr double DEFAULT_RATIO_LENGTH = 5.0
 
static constexpr double DEFAULT_RATIO_WIDTH = 5.0
 
static const LINE_ENDING_STYLE s_defaultChoiceOrder []
 Dropdown display order for line ending style choosers.
 
static const int s_defaultChoiceCount
 

Private Attributes

LINE_ENDING_STYLE m_style
 
int m_length
 Along-line axis. 0 = auto (ratio * line width).
 
int m_width
 Perpendicular axis. 0 = auto.
 
STROKE_PARAMS m_stroke
 

Detailed Description

Decorative shape (arrowhead, circle, square) at the start or end of a graphic line, arc, or bezier.

Closed arrows are tip-anchored at the line endpoint and extend back along the line. Open arrows are vertex-anchored at the endpoint and do not shorten the line body. Circles and squares are centered on the endpoint.

Definition at line 61 of file line_ending.h.

Constructor & Destructor Documentation

◆ LINE_ENDING() [1/2]

LINE_ENDING::LINE_ENDING ( )
inline

Definition at line 64 of file line_ending.h.

References DEFAULT, m_length, m_stroke, m_style, m_width, NONE, and UNSPECIFIED.

Referenced by operator!=(), and operator==().

◆ LINE_ENDING() [2/2]

LINE_ENDING::LINE_ENDING ( LINE_ENDING_STYLE aStyle,
int aLength = 0,
int aWidth = 0,
int aStrokeWidth = 0 )
inline

Definition at line 72 of file line_ending.h.

References DEFAULT, m_length, m_stroke, m_style, m_width, and UNSPECIFIED.

Member Function Documentation

◆ Draw()

◆ Format()

◆ GetCurveOrientationDepth()

int LINE_ENDING::GetCurveOrientationDepth ( int aLineWidth) const

Return how far along a curved body to look when orienting this ending.

This is separate from line-body shortening. Open arrows do not shorten the line body, but they still extend behind the endpoint and need that visual length when aligning to curves.

Definition at line 111 of file line_ending.cpp.

References ARROW_OPEN, GetEffectiveSize(), GetShortenDepth(), m_style, and VECTOR2< T >::x.

Referenced by checkCurveOrientationDepth(), and EDA_SHAPE::GetEndingTangents().

◆ GetEffectiveSize()

VECTOR2I LINE_ENDING::GetEffectiveSize ( int aLineWidth) const

Return the rendered size per axis, applying auto-sizing when length or width is 0.

When one axis is 0 and the other is set, the 0 axis inherits the set value.

Definition at line 63 of file line_ending.cpp.

References DEFAULT_RATIO_LENGTH, DEFAULT_RATIO_WIDTH, KiROUND(), m_length, and m_width.

Referenced by checkEffectiveSize(), GetCurveOrientationDepth(), GetShapes(), and GetShortenDepth().

◆ GetLength()

int LINE_ENDING::GetLength ( ) const
inline

Along-line size. 0 = auto.

Definition at line 84 of file line_ending.h.

References m_length.

Referenced by kiapi::common::PackLineEnding().

◆ GetShapes()

void LINE_ENDING::GetShapes ( const VECTOR2I & aPoint,
const EDA_ANGLE & aTangent,
int aLineWidth,
std::vector< VECTOR2I > & aPolygon ) const

Generate ending geometry as polygon vertices at the given point and direction.

ARROW_OPEN produces an open 3-point polyline; all others produce closed polygons.

Parameters
aTangentOutward-facing tangent direction at the endpoint.

Definition at line 120 of file line_ending.cpp.

References ARROW, ARROW_OPEN, CIRCLE, GetEffectiveSize(), KiROUND(), M_PI, m_style, NONE, RotatePoint(), SQUARE, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by addLineEndingEffectiveShapes(), addLineEndingPolygon(), BOARD_ADAPTER::addShape(), BOOST_AUTO_TEST_CASE(), EXPORTER_STEP::buildGraphic3DShape(), Draw(), EDA_SHAPE::GetLineEndingsBoundingBox(), MakeLineEndingBitmap(), and Plot().

◆ GetShortenDepth()

int LINE_ENDING::GetShortenDepth ( int aLineWidth) const

Return how far the line should be shortened at this ending.

Arrow: full length. Circle/Square: half length. Arrow_Open/None: 0. Reduced by strokeWidth/2 when stroked.

Definition at line 88 of file line_ending.cpp.

References ARROW, ARROW_OPEN, GetEffectiveSize(), m_stroke, m_style, NONE, and VECTOR2< T >::x.

Referenced by checkShortenDepth(), GetCurveOrientationDepth(), MakeLineEndingBitmap(), and EDA_SHAPE::ShortenSegmentForEndings().

◆ GetStroke()

const STROKE_PARAMS & LINE_ENDING::GetStroke ( ) const
inline

Definition at line 103 of file line_ending.h.

References m_stroke.

Referenced by kiapi::common::PackLineEnding().

◆ GetStrokeWidth()

int LINE_ENDING::GetStrokeWidth ( ) const
inline

Outline stroke width.

0 = sharp/filled (default), >0 = stroked outline with line shortening reduced by strokeWidth/2.

Definition at line 100 of file line_ending.h.

References m_stroke.

Referenced by addLineEndingEffectiveShapes(), addLineEndingPolygon(), BOARD_ADAPTER::addShape(), EXPORTER_STEP::buildGraphic3DShape(), EDA_SHAPE::GetLineEndingsBoundingBox(), and kiapi::common::PackLineEnding().

◆ GetStyle()

◆ GetWidth()

int LINE_ENDING::GetWidth ( ) const
inline

Perpendicular size. 0 = auto.

Definition at line 87 of file line_ending.h.

References m_width.

Referenced by kiapi::common::PackLineEnding().

◆ operator!=()

bool LINE_ENDING::operator!= ( const LINE_ENDING & aOther) const
inline

Definition at line 138 of file line_ending.h.

References LINE_ENDING().

◆ operator==()

bool LINE_ENDING::operator== ( const LINE_ENDING & aOther) const

Definition at line 266 of file line_ending.cpp.

References LINE_ENDING(), m_length, m_stroke, m_style, and m_width.

◆ Plot()

void LINE_ENDING::Plot ( PLOTTER * aPlotter,
const VECTOR2I & aPoint,
const EDA_ANGLE & aTangent,
int aLineWidth,
void * aData = nullptr ) const

◆ SetLength()

void LINE_ENDING::SetLength ( int aLength)
inline

◆ SetStroke()

void LINE_ENDING::SetStroke ( const STROKE_PARAMS & aStroke)
inline

◆ SetStrokeWidth()

void LINE_ENDING::SetStrokeWidth ( int aWidth)
inline

Definition at line 101 of file line_ending.h.

References m_stroke.

◆ SetStyle()

void LINE_ENDING::SetStyle ( LINE_ENDING_STYLE aStyle)
inline

◆ SetUniformSize()

void LINE_ENDING::SetUniformSize ( int aSize)
inline

Definition at line 90 of file line_ending.h.

References m_length, and m_width.

◆ SetWidth()

void LINE_ENDING::SetWidth ( int aWidth)
inline

◆ StyleToChoiceIndex()

int LINE_ENDING::StyleToChoiceIndex ( LINE_ENDING_STYLE aStyle)
static

Return the dropdown index for the given style, or 0 (NONE) if not found.

Definition at line 51 of file line_ending.cpp.

References s_defaultChoiceCount, and s_defaultChoiceOrder.

Referenced by DIALOG_LINE_PROPERTIES::TransferDataToWindow(), and DIALOG_SHAPE_PROPERTIES::TransferDataToWindow().

◆ StyleToToken()

wxString LINE_ENDING::StyleToToken ( LINE_ENDING_STYLE aStyle)
static

Definition at line 275 of file line_ending.cpp.

References ARROW, ARROW_OPEN, CIRCLE, NONE, and SQUARE.

Referenced by Format().

◆ TokenToStyle()

LINE_ENDING_STYLE LINE_ENDING::TokenToStyle ( const wxString & aToken)
static

Definition at line 289 of file line_ending.cpp.

References ARROW, ARROW_OPEN, CIRCLE, NONE, and SQUARE.

Member Data Documentation

◆ DEFAULT_RATIO_LENGTH

◆ DEFAULT_RATIO_WIDTH

double LINE_ENDING::DEFAULT_RATIO_WIDTH = 5.0
staticconstexpr

Definition at line 153 of file line_ending.h.

Referenced by GetEffectiveSize(), and MakeLineEndingBitmap().

◆ m_length

int LINE_ENDING::m_length
private

Along-line axis. 0 = auto (ratio * line width).

Definition at line 169 of file line_ending.h.

Referenced by Format(), GetEffectiveSize(), GetLength(), LINE_ENDING(), LINE_ENDING(), operator==(), SetLength(), and SetUniformSize().

◆ m_stroke

◆ m_style

◆ m_width

int LINE_ENDING::m_width
private

Perpendicular axis. 0 = auto.

Definition at line 170 of file line_ending.h.

Referenced by Format(), GetEffectiveSize(), GetWidth(), LINE_ENDING(), LINE_ENDING(), operator==(), SetUniformSize(), and SetWidth().

◆ s_defaultChoiceCount

const int LINE_ENDING::s_defaultChoiceCount
static
Initial value:
=
static_cast<int>( std::size( LINE_ENDING::s_defaultChoiceOrder ) )
static const LINE_ENDING_STYLE s_defaultChoiceOrder[]
Dropdown display order for line ending style choosers.
Definition line_ending.h:38

Definition at line 160 of file line_ending.h.

Referenced by StyleToChoiceIndex(), DIALOG_LINE_PROPERTIES::TransferDataFromWindow(), and DIALOG_SHAPE_PROPERTIES::TransferDataFromWindow().

◆ s_defaultChoiceOrder

const LINE_ENDING_STYLE LINE_ENDING::s_defaultChoiceOrder
static

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