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
 
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 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;
46  m_Angle = 0;
47  m_Width = 0;
48 }
PCB_COMPONENT(PCB_CALLBACKS *aCallbacks, BOARD *aBoard)

References 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 189 of file pcb_arc.cpp.

190 {
192 
193  m_board->Add( arc, ADD_MODE::APPEND );
194 
195  arc->SetFilled( false );
196  arc->SetLayer( m_KiCadLayer );
197  arc->SetCenter( wxPoint( m_positionX, m_positionY ) );
198  arc->SetStart( wxPoint( m_StartX, m_StartY ) );
199  arc->SetArcAngleAndEnd( -m_Angle );
200  arc->SetWidth( m_Width );
201 }
void SetFilled(bool aFlag)
Definition: eda_shape.h:83
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:161
void SetArcAngleAndEnd(double aAngle, bool aCheckNegativeAngle=false)
Set the end point from the angle center and start.
Definition: eda_shape.cpp:509
void SetStart(const wxPoint &aStart)
Definition: eda_shape.h:101
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Adds an item to the container.
Definition: board.cpp:608
void SetWidth(int aWidth)
Definition: eda_shape.h:88
void SetCenter(const wxPoint &aCenter)
Definition: eda_shape.cpp:416

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(), and EDA_SHAPE::SetWidth().

◆ AddToFootprint()

void PCB_ARC::AddToFootprint ( FOOTPRINT aFootprint)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 170 of file pcb_arc.cpp.

171 {
173  {
174  FP_SHAPE* arc = new FP_SHAPE( aFootprint, IsCircle() ? SHAPE_T::CIRCLE : SHAPE_T::ARC );
175  aFootprint->Add( arc );
176 
177  arc->SetCenter0( wxPoint( m_positionX, m_positionY ) );
178  arc->SetStart0( wxPoint( m_StartX, m_StartY ) );
179  arc->SetArcAngleAndEnd0( -m_Angle );
180 
181  arc->SetWidth( m_Width );
182  arc->SetLayer( m_KiCadLayer );
183 
184  arc->SetDrawCoord();
185  }
186 }
virtual void SetLayer(PCB_LAYER_ID aLayer)
Set the layer this item is on.
Definition: board_item.h:161
void SetArcAngleAndEnd0(double aAngle, bool aCheckNegativeAngle=false)
Sets the angle for arcs, and normalizes it within the range 0 - 360 degrees.
Definition: fp_shape.cpp:184
bool IsNonCopperLayer(LAYER_NUM aLayerId)
Test whether a layer is a non copper layer.
Definition: layer_ids.h:807
void SetWidth(int aWidth)
Definition: eda_shape.h:88
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
Definition: fp_shape.cpp:81
void SetStart0(const wxPoint &aPoint)
Definition: fp_shape.h:111
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT) override
Removes an item from the container.
Definition: footprint.cpp:513
void SetCenter0(const wxPoint &aPt)
Definition: fp_shape.cpp:158

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(), and EDA_SHAPE::SetWidth().

◆ Flip()

void PCB_ARC::Flip ( )
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 159 of file pcb_arc.cpp.

160 {
162 
163  m_StartX = -m_StartX;
164  m_Angle = -m_Angle;
165 
167 }
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 ( const wxString &  aNetName) const
inlineinherited

◆ IsCircle()

bool PCB_ARC::IsCircle ( )
private

Definition at line 204 of file pcb_arc.cpp.

205 {
206  return ( m_Angle == 3600 );
207 }

References 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  double a = 0.0;
61  int r = 0;
62  int endX = 0;
63  int endY = 0;
64 
65  m_PCadLayer = aLayer;
67 
68  if( FindNode( aNode, wxT( "width" ) ) )
69  {
70  SetWidth( FindNode( aNode, wxT( "width" ) )->GetNodeContent(), aDefaultUnits, &m_Width,
71  aActualConversion );
72  }
73 
74  if( aNode->GetName() == wxT( "triplePointArc" ) )
75  {
76  // center point
77  lNode = FindNode( aNode, wxT( "pt" ) );
78 
79  if( lNode )
80  {
81  SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
82  aActualConversion );
83  }
84 
85  // start point
86  if( lNode )
87  lNode = lNode->GetNext();
88 
89  if( lNode )
90  {
91  SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_StartX, &m_StartY,
92  aActualConversion );
93  }
94 
95  // end point
96  if( lNode )
97  lNode = lNode->GetNext();
98 
99  if( lNode )
100  SetPosition( lNode->GetNodeContent(), aDefaultUnits, &endX, &endY, aActualConversion );
101 
102  if( m_StartX == endX && m_StartY == endY )
103  {
104  m_Angle = 3600;
105  }
106  else
107  {
108  double alpha1 = ArcTangente( m_StartY - m_positionY, m_StartX - m_positionX );
109  double alpha2 = ArcTangente( endY - m_positionY, endX - m_positionX );
110  m_Angle = alpha1 - alpha2;
111 
113  }
114  }
115  else if( aNode->GetName() == wxT( "arc" ) )
116  {
117  lNode = FindNode( aNode, wxT( "pt" ) );
118 
119  if( lNode )
120  {
121  SetPosition( lNode->GetNodeContent(), aDefaultUnits, &m_positionX, &m_positionY,
122  aActualConversion );
123  }
124 
125  lNode = FindNode( aNode, wxT( "radius" ) );
126 
127  if( lNode)
128  {
129  SetWidth( FindNode( aNode, wxT( "radius" ) )->GetNodeContent(), aDefaultUnits, &r,
130  aActualConversion );
131  }
132 
133 
134  lNode = FindNode( aNode, wxT( "startAngle" ) );
135 
136  if( lNode )
137  a = StrToInt1Units( lNode->GetNodeContent() );
138 
139  lNode = FindNode( aNode, wxT( "sweepAngle" ) );
140 
141  if( lNode )
142  m_Angle = StrToInt1Units( lNode->GetNodeContent() );
143 
144  m_StartX = m_positionX + KiROUND( cosdecideg( r, a ) );
145  m_StartY = m_positionY - KiROUND( sindecideg( r, a ) );
146  }
147 }
void SetWidth(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:290
E_SERIE r
Definition: eserie.cpp:41
PCB_LAYER_ID GetKiCadLayer() const
Definition: pcb_component.h:56
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:452
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:443
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:73
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:183
int StrToInt1Units(const wxString &aStr)
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)

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(), r, PCAD2KICAD::SetPosition(), PCAD2KICAD::SetWidth(), sindecideg(), and PCAD2KICAD::StrToInt1Units().

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 150 of file pcb_arc.cpp.

151 {
152  PCB_COMPONENT::SetPosOffset( aX_offs, aY_offs );
153 
154  m_StartX += aX_offs;
155  m_StartY += aY_offs;
156 }
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 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: