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 &aDefaultMeasurementUnit, 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 (wxString aNetName) const
 

Public Attributes

int m_StartX
 
int m_StartY
 
double 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
 
int 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 39 of file pcb_arc.h.

Constructor & Destructor Documentation

◆ PCB_ARC()

PCAD2KICAD::PCB_ARC::PCB_ARC ( PCB_CALLBACKS aCallbacks,
BOARD aBoard 
)

Definition at line 40 of file pcb_arc.cpp.

40  : PCB_COMPONENT( aCallbacks, aBoard )
41 {
42  m_objType = wxT( 'A' );
43  m_StartX = 0;
44  m_StartY = 0;
45  m_Angle = 0;
46  m_Width = 0;
47 }
PCB_COMPONENT(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)

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

◆ ~PCB_ARC()

PCAD2KICAD::PCB_ARC::~PCB_ARC ( )

Definition at line 50 of file pcb_arc.cpp.

51 {
52 }

Member Function Documentation

◆ AddToBoard()

void PCAD2KICAD::PCB_ARC::AddToBoard ( )
overridevirtual

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 181 of file pcb_arc.cpp.

182 {
183  PCB_SHAPE* arc = new PCB_SHAPE( m_board );
184 
185  m_board->Add( arc, ADD_MODE::APPEND );
186 
187  arc->SetShape( IsCircle() ? S_CIRCLE : S_ARC );
188  arc->SetFilled( false );
189  arc->SetLayer( m_KiCadLayer );
190  arc->SetStart( wxPoint( m_positionX, m_positionY ) );
191  arc->SetEnd( wxPoint( m_StartX, m_StartY ) );
192  arc->SetAngle( -m_Angle );
193  arc->SetWidth( m_Width );
194 }
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:194
void SetFilled(bool aFlag)
Definition: pcb_shape.h:94
Arcs (with rounded ends)
Definition: board_item.h:52
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:563
void SetShape(PCB_SHAPE_TYPE_T aShape)
Definition: pcb_shape.h:129
void SetStart(const wxPoint &aStart)
Definition: pcb_shape.h:148
void SetWidth(int aWidth)
Definition: pcb_shape.h:117
ring
Definition: board_item.h:53
virtual void SetAngle(double aAngle, bool aUpdateEnd=true)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: pcb_shape.cpp:466
void SetEnd(const wxPoint &aEnd)
Definition: pcb_shape.h:159

References BOARD::Add(), APPEND, 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, S_ARC, S_CIRCLE, PCB_SHAPE::SetAngle(), PCB_SHAPE::SetEnd(), PCB_SHAPE::SetFilled(), BOARD_ITEM::SetLayer(), PCB_SHAPE::SetShape(), PCB_SHAPE::SetStart(), and PCB_SHAPE::SetWidth().

◆ AddToFootprint()

void PCAD2KICAD::PCB_ARC::AddToFootprint ( FOOTPRINT aFootprint)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 159 of file pcb_arc.cpp.

160 {
162  {
163  FP_SHAPE* arc = new FP_SHAPE( aFootprint, ( IsCircle() ? S_CIRCLE : S_ARC ) );
164  aFootprint->Add( arc );
165 
166  arc->m_Start0 = wxPoint( m_positionX, m_positionY );
167  arc->m_End0 = wxPoint( m_StartX, m_StartY );
168 
169  // Setting angle will set m_ThirdPoint0, so must be done after setting
170  // m_Start0 and m_End0
171  arc->SetAngle( -m_Angle );
172 
173  arc->SetWidth( m_Width );
174  arc->SetLayer( m_KiCadLayer );
175 
176  arc->SetDrawCoord();
177  }
178 }
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:194
Arcs (with rounded ends)
Definition: board_item.h:52
bool IsNonCopperLayer(LAYER_NUM aLayerId)
Test whether a layer is a non copper layer.
void SetAngle(double aAngle, bool aUpdateEnd=true) override
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: fp_shape.cpp:142
wxPoint m_End0
End point, relative to footprint origin, orient 0.
Definition: fp_shape.h:161
wxPoint m_Start0
Start point or center, relative to footprint origin, orient 0.
Definition: fp_shape.h:160
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:82
void SetWidth(int aWidth)
Definition: pcb_shape.h:117
ring
Definition: board_item.h:53
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:468

References FOOTPRINT::Add(), IsCircle(), IsNonCopperLayer(), m_Angle, FP_SHAPE::m_End0, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, FP_SHAPE::m_Start0, m_StartX, m_StartY, m_Width, S_ARC, S_CIRCLE, FP_SHAPE::SetAngle(), FP_SHAPE::SetDrawCoord(), BOARD_ITEM::SetLayer(), and PCB_SHAPE::SetWidth().

◆ Flip()

void PCAD2KICAD::PCB_ARC::Flip ( )
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 148 of file pcb_arc.cpp.

149 {
151 
152  m_StartX = -m_StartX;
153  m_Angle = -m_Angle;
154 
156 }
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Definition: lset.cpp:521

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

◆ GetKiCadLayer()

◆ GetNetCode()

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

◆ IsCircle()

bool PCAD2KICAD::PCB_ARC::IsCircle ( )
private

Definition at line 197 of file pcb_arc.cpp.

198 {
199  return ( m_Angle == 3600 );
200 }

References m_Angle.

Referenced by AddToBoard(), and AddToFootprint().

◆ Parse()

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

Definition at line 55 of file pcb_arc.cpp.

59 {
60  XNODE* lNode;
61  double a = 0.0;
62  int r = 0;
63  int endX = 0;
64  int endY = 0;
65 
66  m_PCadLayer = aLayer;
68 
69  if( FindNode( aNode, wxT( "width" ) ) )
70  SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(),
71  aDefaultMeasurementUnit, &m_Width, aActualConversion );
72 
73  if( aNode->GetName() == wxT( "triplePointArc" ) )
74  {
75  // center point
76  lNode = FindNode( aNode, wxT( "pt" ) );
77 
78  if( lNode )
79  SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
80  &m_positionX, &m_positionY, aActualConversion );
81 
82  // start point
83  if( lNode )
84  lNode = lNode->GetNext();
85 
86  if( lNode )
87  SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
88  &m_StartX, &m_StartY, aActualConversion );
89 
90  // end point
91  if( lNode )
92  lNode = lNode->GetNext();
93 
94  if( lNode )
95  SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
96  &endX, &endY, aActualConversion );
97 
98  if( m_StartX == endX && m_StartY == endY )
99  {
100  m_Angle = 3600;
101  }
102  else
103  {
104  double alpha1 = ArcTangente( m_StartY - m_positionY, m_StartX - m_positionX );
105  double alpha2 = ArcTangente( endY - m_positionY, endX - m_positionX );
106  m_Angle = alpha1 - alpha2;
107 
109  }
110  }
111  else if( aNode->GetName() == wxT( "arc" ) )
112  {
113  lNode = FindNode( aNode, wxT( "pt" ) );
114 
115  if( lNode )
116  SetPosition( lNode->GetNodeContent(), aDefaultMeasurementUnit,
117  &m_positionX, &m_positionY, aActualConversion );
118 
119  lNode = FindNode( aNode, wxT( "radius" ) );
120  if( lNode)
121  SetWidth( FindNode( aNode, wxT( "radius" ) )->GetNodeContent(),
122  aDefaultMeasurementUnit, &r, aActualConversion );
123 
124 
125  lNode = FindNode( aNode, wxT( "startAngle" ) );
126  if( lNode )
127  a = StrToInt1Units( lNode->GetNodeContent() );
128 
129  lNode = FindNode( aNode, wxT( "sweepAngle" ) );
130  if( lNode )
131  m_Angle = StrToInt1Units( lNode->GetNodeContent() );
132 
133  m_StartX = m_positionX + KiROUND( cosdecideg( r, a ) );
134  m_StartY = m_positionY - KiROUND( sindecideg( r, a ) );
135  }
136 }
void SetPosition(wxString aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
void SetWidth(wxString aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:288
PCB_LAYER_ID GetKiCadLayer() const
Definition: pcb_component.h:70
Hold an XML or S-expression element.
Definition: xnode.h:43
double cosdecideg(double r, double a)
Circle generation utility: computes r * cos(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:439
XNODE * GetNext() const
Definition: xnode.h:67
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:430
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
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:68
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:182
int StrToInt1Units(const wxString &aStr)

References ArcTangente(), cosdecideg(), 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, NORMALIZE_ANGLE_POS(), PCAD2KICAD::SetPosition(), PCAD2KICAD::SetWidth(), sindecideg(), and PCAD2KICAD::StrToInt1Units().

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

◆ SetPosOffset()

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

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 139 of file pcb_arc.cpp.

140 {
141  PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
142 
143  m_StartX += aX_offs;
144  m_StartY += aY_offs;
145 }
virtual void SetPosOffset(int aX_offs, int aY_offs)

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

Member Data Documentation

◆ m_Angle

double PCAD2KICAD::PCB_ARC::m_Angle

Definition at line 44 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 42 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 43 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 48 of file pcb_component.h.

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

◆ m_uuid

KIID PCAD2KICAD::PCB_COMPONENT::m_uuid
inherited

Definition at line 52 of file pcb_component.h.

◆ m_Width

int PCAD2KICAD::PCB_ARC::m_Width

Definition at line 45 of file pcb_arc.h.

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


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