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< wxPointm_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 44 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(), DRAWSEGMENT::SetWidth(), and wxPoint::x.

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

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

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

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

References m_End, m_Poly, and m_Start.

74 {
75  m_Start += aMoveVector;
76  m_End += aMoveVector;
77 
78  for( auto& corner : m_Poly )
79  {
80  corner += aMoveVector;
81  }
82 }
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: