KiCad PCB EDA Suite
PAD_CS_PRIMITIVE Class Reference

Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom pad full shape from a set of primitives. More...

#include <class_pad.h>

Public Member Functions

 PAD_CS_PRIMITIVE (STROKE_T aShape)
 
wxPoint GetCenter ()
 
wxPoint GetArcStart ()
 returns the center of a circle or arc More...
 
void Move (wxPoint aMoveVector)
 returns the start point of an arc More...
 
void ExportTo (DRAWSEGMENT *aTarget)
 Export the PAD_CS_PRIMITIVE parameters to a DRAWSEGMENT useful to draw a primitive shape. More...
 
void ExportTo (EDGE_MODULE *aTarget)
 Export the PAD_CS_PRIMITIVE parameters to a EDGE_MODULE useful to convert a primitive shape to a EDGE_MODULE shape for editing in footprint editor. More...
 

Public Attributes

STROKE_T m_Shape
 
int m_Thickness
 S_SEGMENT, S_ARC, S_CIRCLE, S_POLYGON only (same as DRAWSEGMENT) More...
 
int m_Radius
 thickness of segment or outline For filled S_CIRCLE shape, thickness = 0. More...
 
double m_ArcAngle
 radius of a circle More...
 
wxPoint m_Start
 angle of an arc, from its starting point, in 0.1 deg More...
 
wxPoint m_End
 is also the center of the circle and arc More...
 
wxPoint m_Ctrl1
 is also the start point of the arc More...
 
wxPoint m_Ctrl2
 Bezier Control point 1. More...
 
std::vector< wxPoint > m_Poly
 Bezier Control point 2. More...
 

Detailed Description

Helper class to handle a primitive (basic shape: polygon, segment, circle or arc) to build a custom pad full shape from a set of primitives.

Definition at line 91 of file class_pad.h.

Constructor & Destructor Documentation

◆ PAD_CS_PRIMITIVE()

PAD_CS_PRIMITIVE::PAD_CS_PRIMITIVE ( STROKE_T  aShape)
inline

Definition at line 106 of file class_pad.h.

106  :
107  m_Shape( aShape ), m_Thickness( 0 ), m_Radius( 0 ), m_ArcAngle( 0 )
108  {
109  }
int m_Radius
thickness of segment or outline For filled S_CIRCLE shape, thickness = 0.
Definition: class_pad.h:98
STROKE_T m_Shape
Definition: class_pad.h:94
int m_Thickness
S_SEGMENT, S_ARC, S_CIRCLE, S_POLYGON only (same as DRAWSEGMENT)
Definition: class_pad.h:95
double m_ArcAngle
radius of a circle
Definition: class_pad.h:99

Member Function Documentation

◆ ExportTo() [1/2]

void PAD_CS_PRIMITIVE::ExportTo ( DRAWSEGMENT aTarget)

Export the PAD_CS_PRIMITIVE parameters to a DRAWSEGMENT useful to draw a primitive shape.

Parameters
aTargetis the DRAWSEGMENT to initialize

Definition at line 45 of file pad_custom_shape_functions.cpp.

46 {
47  aTarget->SetShape( m_Shape );
48  aTarget->SetWidth( m_Thickness );
49  aTarget->SetStart( m_Start );
50  aTarget->SetEnd( m_End );
51  aTarget->SetBezControl1( m_Ctrl1 );
52  aTarget->SetBezControl2( m_Ctrl2 );
53 
54  // in a DRAWSEGMENT the radius of a circle is calculated from the
55  // center and one point on the circle outline (stored in m_End)
56  if( m_Shape == S_CIRCLE )
57  {
58  wxPoint end = m_Start;
59  end.x += m_Radius;
60  aTarget->SetEnd( end );
61  }
62 
63  aTarget->SetAngle( m_ArcAngle );
64  aTarget->SetPolyPoints( m_Poly );
65 }
void SetShape(STROKE_T aShape)
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:100
void SetBezControl2(const wxPoint &aPoint)
wxPoint m_Ctrl1
is also the start point of the arc
Definition: class_pad.h:102
int m_Radius
thickness of segment or outline For filled S_CIRCLE shape, thickness = 0.
Definition: class_pad.h:98
std::vector< wxPoint > m_Poly
Bezier Control point 2.
Definition: class_pad.h:104
wxPoint m_End
is also the center of the circle and arc
Definition: class_pad.h:101
STROKE_T m_Shape
Definition: class_pad.h:94
wxPoint m_Ctrl2
Bezier Control point 1.
Definition: class_pad.h:103
void SetStart(const wxPoint &aStart)
void SetPolyPoints(const std::vector< wxPoint > &aPoints)
int m_Thickness
S_SEGMENT, S_ARC, S_CIRCLE, S_POLYGON only (same as DRAWSEGMENT)
Definition: class_pad.h:95
void SetEnd(const wxPoint &aEnd)
void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
double m_ArcAngle
radius of a circle
Definition: class_pad.h:99
void SetBezControl1(const wxPoint &aPoint)
void SetWidth(int aWidth)

References m_ArcAngle, m_Ctrl1, m_Ctrl2, m_End, m_Poly, m_Radius, m_Shape, m_Start, m_Thickness, S_CIRCLE, DRAWSEGMENT::SetAngle(), DRAWSEGMENT::SetBezControl1(), DRAWSEGMENT::SetBezControl2(), DRAWSEGMENT::SetEnd(), DRAWSEGMENT::SetPolyPoints(), DRAWSEGMENT::SetShape(), DRAWSEGMENT::SetStart(), and DRAWSEGMENT::SetWidth().

Referenced by ExportTo(), DIALOG_PAD_PROPERTIES::OnPaintShowPanel(), and DIALOG_PAD_PROPERTIES::redraw().

◆ ExportTo() [2/2]

void PAD_CS_PRIMITIVE::ExportTo ( EDGE_MODULE aTarget)

Export the PAD_CS_PRIMITIVE parameters to a EDGE_MODULE useful to convert a primitive shape to a EDGE_MODULE shape for editing in footprint editor.

Parameters
aTargetis the EDGE_MODULE to initialize

Definition at line 68 of file pad_custom_shape_functions.cpp.

69 {
70  ExportTo( static_cast<DRAWSEGMENT*>( aTarget ) );
71  // Initialize coordinates specific to the EDGE_MODULE (m_Start0 and m_End0)
72  aTarget->SetLocalCoord();
73 }
void ExportTo(DRAWSEGMENT *aTarget)
Export the PAD_CS_PRIMITIVE parameters to a DRAWSEGMENT useful to draw a primitive shape.
void SetLocalCoord()
Set relative coordinates from draw coordinates.

References ExportTo(), and EDGE_MODULE::SetLocalCoord().

◆ GetArcStart()

wxPoint PAD_CS_PRIMITIVE::GetArcStart ( )
inline

returns the center of a circle or arc

Definition at line 113 of file class_pad.h.

113 { return m_End; }
wxPoint m_End
is also the center of the circle and arc
Definition: class_pad.h:101

References m_End.

◆ GetCenter()

wxPoint PAD_CS_PRIMITIVE::GetCenter ( )
inline

Definition at line 112 of file class_pad.h.

112 { return m_Start; }
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:100

References m_Start.

◆ Move()

void PAD_CS_PRIMITIVE::Move ( wxPoint  aMoveVector)

returns the start point of an arc

Move the primitive

Parameters
aMoveVectoris the deplacement vector

Definition at line 76 of file pad_custom_shape_functions.cpp.

77 {
78  m_Start += aMoveVector;
79  m_End += aMoveVector;
80  m_Ctrl1 += aMoveVector;
81  m_Ctrl2 += aMoveVector;
82 
83  for( auto& corner : m_Poly )
84  {
85  corner += aMoveVector;
86  }
87 }
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:100
wxPoint m_Ctrl1
is also the start point of the arc
Definition: class_pad.h:102
std::vector< wxPoint > m_Poly
Bezier Control point 2.
Definition: class_pad.h:104
wxPoint m_End
is also the center of the circle and arc
Definition: class_pad.h:101
wxPoint m_Ctrl2
Bezier Control point 1.
Definition: class_pad.h:103

References m_Ctrl1, m_Ctrl2, m_End, m_Poly, and m_Start.

Member Data Documentation

◆ m_ArcAngle

◆ m_Ctrl1

◆ m_Ctrl2

◆ m_End

◆ m_Poly

◆ m_Radius

◆ m_Shape

◆ m_Start

◆ m_Thickness


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