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, wxString aDefaultMeasurementUnit, wxString aActualConversion)
 
virtual void SetPosOffset (int aX_offs, int aY_offs) override
 
virtual void Flip () override
 
void AddToModule (MODULE *aModule) override
 
void AddToBoard () override
 
PCB_LAYER_ID GetKiCadLayer ()
 
int GetNewTimestamp ()
 
int GetNetCode (wxString aNetName)
 

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
 
int m_timestamp
 
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
 

Detailed Description

Definition at line 39 of file pcb_arc.h.

Constructor & Destructor Documentation

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

Definition at line 40 of file pcb_arc.cpp.

References m_angle, PCAD2KICAD::PCB_COMPONENT::m_objType, m_startX, m_startY, and m_width.

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)
PCAD2KICAD::PCB_ARC::~PCB_ARC ( )

Definition at line 50 of file pcb_arc.cpp.

51 {
52 }

Member Function Documentation

void PCAD2KICAD::PCB_ARC::AddToBoard ( )
overridevirtual

Implements PCAD2KICAD::PCB_COMPONENT.

Definition at line 178 of file pcb_arc.cpp.

References BOARD::Add(), ADD_APPEND, 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, PCAD2KICAD::PCB_COMPONENT::m_timestamp, m_width, S_ARC, DRAWSEGMENT::SetAngle(), DRAWSEGMENT::SetEnd(), BOARD_ITEM::SetLayer(), DRAWSEGMENT::SetShape(), DRAWSEGMENT::SetStart(), EDA_ITEM::SetTimeStamp(), and DRAWSEGMENT::SetWidth().

179 {
180  DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
181 
182  m_board->Add( dseg, ADD_APPEND );
183 
184  dseg->SetShape( S_ARC );
185  dseg->SetTimeStamp( m_timestamp );
186  dseg->SetLayer( m_KiCadLayer );
188  dseg->SetEnd( wxPoint( m_startX, m_startY ) );
189  dseg->SetAngle( -m_angle );
190  dseg->SetWidth( m_width );
191 }
void SetShape(STROKE_T aShape)
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
void SetTimeStamp(time_t aNewTimeStamp)
Definition: base_struct.h:203
Arcs (with rounded ends)
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_INSERT) override
>
void SetStart(const wxPoint &aStart)
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...
void SetWidth(int aWidth)
void PCAD2KICAD::PCB_ARC::AddToModule ( MODULE aModule)
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 159 of file pcb_arc.cpp.

References MODULE::GraphicalItems(), IsNonCopperLayer(), m_angle, EDGE_MODULE::m_End0, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, PCAD2KICAD::PCB_COMPONENT::m_positionX, PCAD2KICAD::PCB_COMPONENT::m_positionY, EDGE_MODULE::m_Start0, m_startX, m_startY, m_width, DLIST< T >::PushBack(), S_ARC, DRAWSEGMENT::SetAngle(), EDGE_MODULE::SetDrawCoord(), BOARD_ITEM::SetLayer(), and DRAWSEGMENT::SetWidth().

160 {
162  {
163  EDGE_MODULE* arc = new EDGE_MODULE( aModule, S_ARC );
164  aModule->GraphicalItems().PushBack( arc );
165 
166  arc->SetAngle( -m_angle );
168  arc->m_End0 = wxPoint( m_startX, m_startY );
169 
170  arc->SetWidth( m_width );
171  arc->SetLayer( m_KiCadLayer );
172 
173  arc->SetDrawCoord();
174  }
175 }
virtual void SetLayer(PCB_LAYER_ID aLayer)
Function SetLayer sets the layer this item is on.
DLIST< BOARD_ITEM > & GraphicalItems()
Definition: class_module.h:137
bool IsNonCopperLayer(LAYER_NUM aLayerId)
Function IsNonCopperLayer tests whether a layer is a non copper layer.
wxPoint m_End0
void PushBack(T *aNewElement)
Function PushBack puts aNewElement at the end of the list sequence.
Definition: dlist.h:250
Arcs (with rounded ends)
void SetDrawCoord()
Set draw coordinates (absolute values ) from relative coordinates.
void SetAngle(double aAngle)
Function SetAngle sets the angle for arcs, and normalizes it within the range 0 - 360 degrees...
wxPoint m_Start0
void SetWidth(int aWidth)
void PCAD2KICAD::PCB_ARC::Flip ( )
overridevirtual

Reimplemented from PCAD2KICAD::PCB_COMPONENT.

Definition at line 148 of file pcb_arc.cpp.

References PCAD2KICAD::PCB_COMPONENT::Flip(), FlipLayer(), m_angle, PCAD2KICAD::PCB_COMPONENT::m_KiCadLayer, and m_startX.

149 {
151 
152  m_startX = -m_startX;
153  m_angle = -m_angle;
154 
156 }
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayerId, int aCopperLayersCount)
Function FlippedLayerNumber.
Definition: lset.cpp:445
int PCAD2KICAD::PCB_COMPONENT::GetNewTimestamp ( )
inlineinherited
void PCAD2KICAD::PCB_ARC::Parse ( XNODE aNode,
int  aLayer,
wxString  aDefaultMeasurementUnit,
wxString  aActualConversion 
)
virtual

Definition at line 55 of file pcb_arc.cpp.

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_MODULE::DoLayerContentsObjects().

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 SetWidth(wxString aStr, wxString aDefaultMeasurementUnit, int *aWidth, wxString aActualConversion)
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
int StrToInt1Units(wxString aStr)
void NORMALIZE_ANGLE_POS(T &Angle)
Definition: trigo.h:222
PCB_LAYER_ID GetKiCadLayer()
Definition: pcb_component.h:73
double ArcTangente(int dy, int dx)
Definition: trigo.cpp:271
void SetPosition(wxString aStr, wxString aDefaultMeasurementUnit, int *aX, int *aY, wxString aActualConversion)
Class XNODE holds 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:311
double sindecideg(double r, double a)
Circle generation utility: computes r * sin(a) Where a is in decidegrees, not in radians.
Definition: trigo.h:302
XNODE * FindNode(XNODE *aChild, wxString aTag)
XNODE * GetNext() const
Definition: xnode.h:68
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.

References m_startX, m_startY, and PCAD2KICAD::PCB_COMPONENT::SetPosOffset().

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)

Member Data Documentation

double PCAD2KICAD::PCB_ARC::m_angle

Definition at line 44 of file pcb_arc.h.

Referenced by AddToBoard(), AddToModule(), Flip(), Parse(), and PCB_ARC().

wxString PCAD2KICAD::PCB_COMPONENT::m_compRef
inherited
wxString PCAD2KICAD::PCB_COMPONENT::m_patGraphRefName
inherited
int PCAD2KICAD::PCB_ARC::m_startX

Definition at line 42 of file pcb_arc.h.

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

int PCAD2KICAD::PCB_ARC::m_startY

Definition at line 43 of file pcb_arc.h.

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

int PCAD2KICAD::PCB_COMPONENT::m_tag
inherited

Definition at line 51 of file pcb_component.h.

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

int PCAD2KICAD::PCB_ARC::m_width

Definition at line 45 of file pcb_arc.h.

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


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