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 Rotate (const wxPoint &aRotCentre, double aAngle)
 Rotates the primitive about a point. 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 89 of file class_pad.h.

Constructor & Destructor Documentation

◆ PAD_CS_PRIMITIVE()

PAD_CS_PRIMITIVE::PAD_CS_PRIMITIVE ( STROKE_T  aShape)
inline

Definition at line 104 of file class_pad.h.

104  :
105  m_Shape( aShape ), m_Thickness( 0 ), m_Radius( 0 ), m_ArcAngle( 0 )
106  {
107  }
int m_Radius
thickness of segment or outline For filled S_CIRCLE shape, thickness = 0.
Definition: class_pad.h:96
STROKE_T m_Shape
Definition: class_pad.h:92
int m_Thickness
S_SEGMENT, S_ARC, S_CIRCLE, S_POLYGON only (same as DRAWSEGMENT)
Definition: class_pad.h:93
double m_ArcAngle
radius of a circle
Definition: class_pad.h:97

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 47 of file pad_custom_shape_functions.cpp.

48 {
49  aTarget->SetShape( m_Shape );
50  aTarget->SetWidth( m_Thickness );
51  aTarget->SetStart( m_Start );
52  aTarget->SetEnd( m_End );
53  aTarget->SetBezControl1( m_Ctrl1 );
54  aTarget->SetBezControl2( m_Ctrl2 );
55 
56  // in a DRAWSEGMENT the radius of a circle is calculated from the
57  // center and one point on the circle outline (stored in m_End)
58  if( m_Shape == S_CIRCLE )
59  {
60  wxPoint end = m_Start;
61  end.x += m_Radius;
62  aTarget->SetEnd( end );
63  }
64 
65  aTarget->SetAngle( m_ArcAngle );
66  aTarget->SetPolyPoints( m_Poly );
67 }
void SetShape(STROKE_T aShape)
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:98
void SetBezControl2(const wxPoint &aPoint)
wxPoint m_Ctrl1
is also the start point of the arc
Definition: class_pad.h:100
int m_Radius
thickness of segment or outline For filled S_CIRCLE shape, thickness = 0.
Definition: class_pad.h:96
std::vector< wxPoint > m_Poly
Bezier Control point 2.
Definition: class_pad.h:102
wxPoint m_End
is also the center of the circle and arc
Definition: class_pad.h:99
STROKE_T m_Shape
Definition: class_pad.h:92
wxPoint m_Ctrl2
Bezier Control point 1.
Definition: class_pad.h:101
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:93
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:97
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 70 of file pad_custom_shape_functions.cpp.

71 {
72  ExportTo( static_cast<DRAWSEGMENT*>( aTarget ) );
73  // Initialize coordinates specific to the EDGE_MODULE (m_Start0 and m_End0)
74  aTarget->SetLocalCoord();
75 }
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 111 of file class_pad.h.

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

References m_End.

◆ GetCenter()

wxPoint PAD_CS_PRIMITIVE::GetCenter ( )
inline

Definition at line 110 of file class_pad.h.

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

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 78 of file pad_custom_shape_functions.cpp.

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

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

◆ Rotate()

void PAD_CS_PRIMITIVE::Rotate ( const wxPoint &  aRotCentre,
double  aAngle 
)

Rotates the primitive about a point.

Parameters
aRotCentrecenter of rotation
aAngleangle in tenths of degree

Definition at line 92 of file pad_custom_shape_functions.cpp.

93 {
94  switch( m_Shape )
95  {
96  case S_ARC:
97  case S_SEGMENT:
98  case S_CIRCLE:
99  // these can all be done by just rotating the start and end points
100  RotatePoint( &m_Start, aRotCentre, aAngle );
101  RotatePoint( &m_End, aRotCentre, aAngle );
102  break;
103 
104  case S_POLYGON:
105  for( auto& pt : m_Poly )
106  RotatePoint( &pt, aRotCentre, aAngle );
107 
108  break;
109 
110  case S_CURVE:
111  RotatePoint( &m_Start, aRotCentre, aAngle );
112  RotatePoint( &m_End, aRotCentre, aAngle );
113  RotatePoint( &m_Ctrl1, aRotCentre, aAngle );
114  RotatePoint( &m_Ctrl2, aRotCentre, aAngle );
115 
116  break;
117 
118  case S_RECT:
119  default:
120  // un-handled edge transform
121  wxASSERT_MSG( false, wxT( "PAD_CS_PRIMITIVE::Rotate not implemented for "
123  break;
124  }
125 }
static wxString ShowShape(STROKE_T aShape)
Function ShowShape converts the enum STROKE_T integer value to a wxString.
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:98
polygon (not yet used for tracks, but could be in microwave apps)
usual segment : line with rounded ends
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
wxPoint m_Ctrl1
is also the start point of the arc
Definition: class_pad.h:100
segment with non rounded ends
std::vector< wxPoint > m_Poly
Bezier Control point 2.
Definition: class_pad.h:102
Arcs (with rounded ends)
Bezier Curve.
wxPoint m_End
is also the center of the circle and arc
Definition: class_pad.h:99
STROKE_T m_Shape
Definition: class_pad.h:92
wxPoint m_Ctrl2
Bezier Control point 1.
Definition: class_pad.h:101

References m_Ctrl1, m_Ctrl2, m_End, m_Poly, m_Shape, m_Start, RotatePoint(), S_ARC, S_CIRCLE, S_CURVE, S_POLYGON, S_RECT, S_SEGMENT, and BOARD_ITEM::ShowShape().

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: