KiCad PCB EDA Suite
PCAD2KICAD::PCB_ARC Class Reference

#include <pcb_arc.h>

Inheritance diagram for PCAD2KICAD::PCB_ARC:
PCAD2KICAD::PCB_COMPONENT

Public Member Functions

 PCB_ARC (PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
 
 ~PCB_ARC ()
 
virtual void Parse (XNODE *aNode, int aLayer, const wxString &aDefaultUnits, const wxString &aActualConversion)
 
virtual void SetPosOffset (int aX_offs, int aY_offs) override
 
virtual void Flip () override
 
void AddToFootprint (FOOTPRINT *aFootprint) override
 
void AddToBoard () override
 
PCB_LAYER_ID GetKiCadLayer () const
 
int GetNetCode (const wxString &aNetName) const
 

Public Attributes

int m_StartX
 
int m_StartY
 
EDA_ANGLE m_Angle
 
int m_Width
 
int m_tag
 
char m_objType
 
int m_PCadLayer
 
PCB_LAYER_ID m_KiCadLayer
 
KIID m_uuid
 
int m_positionX
 
int m_positionY
 
EDA_ANGLE m_rotation
 
TTEXTVALUE m_name
 
wxString m_net
 
int m_netCode
 
wxString m_compRef
 
wxString m_patGraphRefName
 

Protected Attributes

PCB_CALLBACKSm_callbacks
 
BOARDm_board
 

Private Member Functions

bool IsCircle ()
 

Detailed Description

Definition at line 38 of file pcb_arc.h.

Constructor & Destructor Documentation

◆ PCB_ARC()

PCB_ARC::PCB_ARC ( PCB_CALLBACKS aCallbacks,
BOARD aBoard 
)

Definition at line 40 of file pcb_arc.cpp.

40 :
41 PCB_COMPONENT( aCallbacks, aBoard )
42{
43 m_objType = wxT( 'A' );
44 m_StartX = 0;
45 m_StartY = 0;
47 m_Width = 0;
48}
EDA_ANGLE m_Angle
Definition: pcb_arc.h:56
PCB_COMPONENT(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:429

References ANGLE_0, m_Angle, PCAD2KICAD::PCB_COMPONENT::m_objType, m_StartX, m_StartY, and m_Width.

◆ ~PCB_ARC()

PCB_ARC::~PCB_ARC ( )

Definition at line 51 of file pcb_arc.cpp.

52{
53}

Member Function Documentation

◆ AddToBoard()

void PCB_ARC::AddToBoard ( )
overridevirtual

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 195 of file pcb_arc.cpp.

196{
198
200
201 arc->SetFilled( false );
202 arc->SetLayer( m_KiCadLayer );
205 arc->SetArcAngleAndEnd( -m_Angle, true );
207}
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:226
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: board.cpp:772
void SetCenter(const VECTOR2I &aCenter)
Definition: eda_shape.cpp:470
void SetFilled(bool aFlag)
Definition: eda_shape.h:95
void SetStart(const VECTOR2I &aStart)
Definition: eda_shape.h:124
void SetArcAngleAndEnd(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
Definition: eda_shape.cpp:596
void SetStroke(const STROKE_PARAMS &aStroke) override
Definition: pcb_shape.h:72
Simple container to manage line stroke parameters.
Definition: stroke_params.h:88
VECTOR2< int > VECTOR2I
Definition: vector2d.h:590

References BOARD::Add(), APPEND, ARC, CIRCLE, IsCircle(), m_Angle, PCAD2KICAD::PCB_COMPONENT::m_board, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, m_StartX, m_StartY, m_Width, EDA_SHAPE::SetArcAngleAndEnd(), EDA_SHAPE::SetCenter(), EDA_SHAPE::SetFilled(), BOARD_ITEM::SetLayer(), EDA_SHAPE::SetStart(), PCB_SHAPE::SetStroke(), and SOLID.

◆ AddToFootprint()

void PCB_ARC::AddToFootprint ( FOOTPRINT aFootprint)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 176 of file pcb_arc.cpp.

177{
179 {
180 FP_SHAPE* arc = new FP_SHAPE( aFootprint, IsCircle() ? SHAPE_T::CIRCLE : SHAPE_T::ARC );
181 aFootprint->Add( arc );
182
185 arc->SetArcAngleAndEnd0( -m_Angle, true );
186
188 arc->SetLayer( m_KiCadLayer );
189
190 arc->SetDrawCoord();
191 }
192}
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
Definition: footprint.cpp:568
void SetStart0(const VECTOR2I &aPoint)
Definition: fp_shape.h:91
virtual void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:80
void SetArcAngleAndEnd0(const EDA_ANGLE &aAngle, bool aCheckNegativeAngle=false)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: fp_shape.cpp:193
void SetCenter0(const VECTOR2I &aPt)
Definition: fp_shape.cpp:161
bool IsNonCopperLayer(int aLayerId)
Test whether a layer is a non copper layer.
Definition: layer_ids.h:838

References FOOTPRINT::Add(), ARC, CIRCLE, IsCircle(), IsNonCopperLayer(), m_Angle, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, m_StartX, m_StartY, m_Width, FP_SHAPE::SetArcAngleAndEnd0(), FP_SHAPE::SetCenter0(), FP_SHAPE::SetDrawCoord(), BOARD_ITEM::SetLayer(), FP_SHAPE::SetStart0(), PCB_SHAPE::SetStroke(), and SOLID.

◆ Flip()

void PCB_ARC::Flip ( )
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 165 of file pcb_arc.cpp.

166{
168
170 m_Angle = -m_Angle;
171
173}
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:544

References PCAD2KICAD::PCB_COMPONENT::Flip(), FlipLayer(), m_Angle, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, and m_StartX.

◆ GetKiCadLayer()

◆ GetNetCode()

int PCAD2KICAD::PCB_COMPONENT::GetNetCode ( const wxString &  aNetName) const
inlineinherited

◆ IsCircle()

bool PCB_ARC::IsCircle ( )
private

Definition at line 210 of file pcb_arc.cpp.

211{
212 return ( m_Angle == ANGLE_360 );
213}
static constexpr EDA_ANGLE & ANGLE_360
Definition: eda_angle.h:435

References ANGLE_360, and m_Angle.

Referenced by AddToBoard(), and AddToFootprint().

◆ Parse()

void PCB_ARC::Parse ( XNODE aNode,
int  aLayer,
const wxString &  aDefaultUnits,
const wxString &  aActualConversion 
)
virtual

Definition at line 56 of file pcb_arc.cpp.

58{
59 XNODE* lNode;
60 int r = 0;
61 VECTOR2I end;
62
63 m_PCadLayer = aLayer;
65
66 if( FindNode( aNode, wxT( "width" ) ) )
67 {
68 SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(), aDefaultUnits, &m_Width,
69 aActualConversion );
70 }
71
72 if( aNode->GetName() == wxT( "triplePointArc" ) )
73 {
74 // center point
75 lNode = FindNode( aNode, wxT( "pt" ) );
76
77 if( lNode )
78 {
79 SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
80 aActualConversion );
81 }
82
83 // start point
84 if( lNode )
85 lNode = lNode->GetNext();
86
87 if( lNode )
88 {
89 SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_StartX, &m_StartY,
90 aActualConversion );
91 }
92
93 // end point
94 if( lNode )
95 lNode = lNode->GetNext();
96
97 if( lNode )
98 {
99 SetPosition( lNode->GetNodeContent(), aDefaultUnits, &end.x, &end.y,
100 aActualConversion );
101 }
102
103 VECTOR2I position( m_positionX, m_positionY );
104 VECTOR2I start( m_StartX, m_StartY );
105
106 if( start == end )
107 {
109 }
110 else
111 {
112 EDA_ANGLE alpha1( start - position );
113 EDA_ANGLE alpha2( end - position );
114 m_Angle = alpha1 - alpha2;
115
117 }
118 }
119 else if( aNode->GetName() == wxT( "arc" ) )
120 {
121 lNode = FindNode( aNode, wxT( "pt" ) );
122
123 if( lNode )
124 {
125 SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
126 aActualConversion );
127 }
128
129 lNode = FindNode( aNode, wxT( "radius" ) );
130
131 if( lNode)
132 {
133 SetWidth( FindNode( aNode, wxT( "radius" ) )->GetNodeContent(), aDefaultUnits, &r,
134 aActualConversion );
135 }
136
137
138 lNode = FindNode( aNode, wxT( "startAngle" ) );
139
140 EDA_ANGLE a = ANGLE_0;
141
142 if( lNode )
143 a = EDA_ANGLE( StrToInt1Units( lNode->GetNodeContent() ), TENTHS_OF_A_DEGREE_T );
144
145 lNode = FindNode( aNode, wxT( "sweepAngle" ) );
146
147 if( lNode )
148 m_Angle = EDA_ANGLE( StrToInt1Units( lNode->GetNodeContent() ), TENTHS_OF_A_DEGREE_T );
149
150 m_StartX = m_positionX + KiROUND( r * a.Cos() );
151 m_StartY = m_positionY - KiROUND( r * a.Sin() );
152 }
153}
EDA_ANGLE Normalize()
Definition: eda_angle.h:249
double Sin() const
Definition: eda_angle.h:206
double Cos() const
Definition: eda_angle.h:221
PCB_LAYER_ID GetKiCadLayer() const
Definition: pcb_component.h:56
Hold an XML or S-expression element.
Definition: xnode.h:44
XNODE * GetNext() const
Definition: xnode.h:67
@ TENTHS_OF_A_DEGREE_T
Definition: eda_angle.h:30
int StrToInt1Units(const wxString &aStr)
void SetWidth(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References ANGLE_0, ANGLE_360, EDA_ANGLE::Cos(), PCAD2KICAD::FindNode(), PCAD2KICAD::PCB_COMPONENT::GetKiCadLayer(), XNODE::GetNext(), KiROUND(), m_Angle, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_PCadLayer, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, m_StartX, m_StartY, m_Width, EDA_ANGLE::Normalize(), PCAD2KICAD::SetPosition(), PCAD2KICAD::SetWidth(), EDA_ANGLE::Sin(), PCAD2KICAD::StrToInt1Units(), TENTHS_OF_A_DEGREE_T, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by PCAD2KICAD::PCB_FOOTPRINT::DoLayerContentsObjects().

◆ SetPosOffset()

void PCB_ARC::SetPosOffset ( int  aX_offs,
int  aY_offs 
)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 156 of file pcb_arc.cpp.

157{
158 PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
159
160 m_StartX += aX_offs;
161 m_StartY += aY_offs;
162}
virtual void SetPosOffset(int aX_offs, int aY_offs)

References m_StartX, m_StartY, and PCAD2KICAD::PCB_COMPONENT::SetPosOffset().

Member Data Documentation

◆ m_Angle

EDA_ANGLE PCAD2KICAD::PCB_ARC::m_Angle

Definition at line 56 of file pcb_arc.h.

Referenced by AddToBoard(), AddToFootprint(), Flip(), IsCircle(), Parse(), and PCB_ARC().

◆ m_board

◆ m_callbacks

◆ m_compRef

wxString PCAD2KICAD::PCB_COMPONENT::m_compRef
inherited

◆ m_KiCadLayer

◆ m_name

◆ m_net

◆ m_netCode

◆ m_objType

◆ m_patGraphRefName

wxString PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName
inherited

◆ m_PCadLayer

◆ m_positionX

◆ m_positionY

◆ m_rotation

◆ m_StartX

int PCAD2KICAD::PCB_ARC::m_StartX

Definition at line 54 of file pcb_arc.h.

Referenced by AddToBoard(), AddToFootprint(), Flip(), Parse(), PCB_ARC(), and SetPosOffset().

◆ m_StartY

int PCAD2KICAD::PCB_ARC::m_StartY

Definition at line 55 of file pcb_arc.h.

Referenced by AddToBoard(), AddToFootprint(), Parse(), PCB_ARC(), and SetPosOffset().

◆ m_tag

int PCAD2KICAD::PCB_COMPONENT::m_tag
inherited

Definition at line 63 of file pcb_component.h.

Referenced by PCAD2KICAD::PCB_COMPONENT::PCB_COMPONENT().

◆ m_uuid

KIID PCAD2KICAD::PCB_COMPONENT::m_uuid
inherited

Definition at line 67 of file pcb_component.h.

◆ m_Width

int PCAD2KICAD::PCB_ARC::m_Width

Definition at line 57 of file pcb_arc.h.

Referenced by AddToBoard(), AddToFootprint(), Parse(), and PCB_ARC().


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