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...
 
std::vector< wxPoint > m_Poly
 is also the start point of the arc 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 ( 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: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

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

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

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

44 {
45  aTarget->SetShape( m_Shape );
46  aTarget->SetWidth( m_Thickness );
47  aTarget->SetStart( m_Start );
48  aTarget->SetEnd( m_End );
49 
50  // in a DRAWSEGMENT the radius of a circle is calculated from the
51  // center and one point on the circle outline (stored in m_End)
52  if( m_Shape == S_CIRCLE )
53  {
54  wxPoint end = m_Start;
55  end.x += m_Radius;
56  aTarget->SetEnd( end );
57  }
58 
59  aTarget->SetAngle( m_ArcAngle );
60  aTarget->SetPolyPoints( m_Poly );
61 }
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
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
is also the start point of the arc
Definition: class_pad.h:102
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
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 SetWidth(int aWidth)
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 64 of file pad_custom_shape_functions.cpp.

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

65 {
66  ExportTo( static_cast<DRAWSEGMENT*>( aTarget ) );
67  // Initialize coordinates specific to the EDGE_MODULE (m_Start0 and m_End0)
68  aTarget->SetLocalCoord();
69 }
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.
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:101
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:100
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 72 of file pad_custom_shape_functions.cpp.

References m_End, m_Poly, and m_Start.

73 {
74  m_Start += aMoveVector;
75  m_End += aMoveVector;
76 
77  for( auto& corner : m_Poly )
78  {
79  corner += aMoveVector;
80  }
81 }
wxPoint m_Start
angle of an arc, from its starting point, in 0.1 deg
Definition: class_pad.h:100
std::vector< wxPoint > m_Poly
is also the start point of the arc
Definition: class_pad.h:102
wxPoint m_End
is also the center of the circle and arc
Definition: class_pad.h:101

Member Data Documentation


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