KiCad PCB EDA Suite
PCAD2KICAD Namespace Reference

Classes

class  PCB
 
class  PCB_ARC
 
class  PCB_CALLBACKS
 
class  PCB_COMPONENT
 
class  PCB_COPPER_POUR
 
class  PCB_CUTOUT
 
class  PCB_FOOTPRINT
 
class  PCB_KEEPOUT
 
class  PCB_LINE
 
class  PCB_NET
 
class  PCB_NET_NODE
 
class  PCB_PAD
 
class  PCB_PAD_SHAPE
 
class  PCB_PLANE
 
class  PCB_POLYGON
 
class  PCB_TEXT
 
class  PCB_VIA
 
class  PCB_VIA_SHAPE
 
struct  TTEXTVALUE
 

Enumerations

enum  TTEXT_JUSTIFY {
  LowerLeft , LowerCenter , LowerRight , UpperLeft ,
  UpperCenter , UpperRight , Left , Center ,
  Right
}
 

Functions

wxString GetWord (wxString *aStr)
 
XNODEFindPinMap (XNODE *aNode)
 
double StrToDoublePrecisionUnits (const wxString &aStr, char aAxe, const wxString &aActualConversion)
 
int StrToIntUnits (const wxString &aStr, char aAxe, const wxString &aActualConversion)
 
wxString GetAndCutWordWithMeasureUnits (wxString *aStr, const wxString &aDefaultMeasurementUnit)
 
int StrToInt1Units (const wxString &aStr)
 
wxString ValidateName (const wxString &aName)
 
wxString ValidateReference (const wxString &aRef)
 
void SetWidth (const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
 
void SetHeight (const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aHeight, const wxString &aActualConversion)
 
void SetPosition (const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
 
void SetDoublePrecisionPosition (const wxString &aStr, const wxString &aDefaultMeasurementUnit, double *aX, double *aY, const wxString &aActualConversion)
 
TTEXT_JUSTIFY GetJustifyIdentificator (const wxString &aJustify)
 
void SetTextParameters (XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
 
void SetFontProperty (XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)
 
void SetTextJustify (EDA_TEXT *aText, TTEXT_JUSTIFY aJustify)
 
int CalculateTextLengthSize (TTEXTVALUE *aText)
 
void CorrectTextPosition (TTEXTVALUE *aValue)
 
void SetTextSizeFromStrokeFontHeight (EDA_TEXT *aText, int aTextHeight)
 
void SetTextSizeFromTrueTypeFontHeight (EDA_TEXT *aText, int aTextHeight)
 
XNODEFindNode (XNODE *aChild, const wxString &aTag)
 
wxString FindNodeGetContent (XNODE *aChild, const wxString &aTag)
 
void InitTTextValue (TTEXTVALUE *aTextValue)
 
 WX_DEFINE_ARRAY (PCB_COMPONENT *, PCB_COMPONENTS_ARRAY)
 
 WX_DEFINE_ARRAY (PCB_NET *, PCB_NETS_ARRAY)
 
 WX_DEFINE_ARRAY (PCB_NET_NODE *, PCB_NET_NODES_ARRAY)
 
 WX_DEFINE_ARRAY (PCB_PAD_SHAPE *, PCB_PAD_SHAPES_ARRAY)
 
void LoadInputFile (const wxString &aFileName, wxXmlDocument *aXmlDoc)
 

Variables

const double TEXT_WIDTH_TO_SIZE_AVERAGE = 0.5
 
const double STROKE_HEIGHT_TO_SIZE = 0.656
 
const double STROKE_WIDTH_TO_SIZE = 0.69
 
const double TRUETYPE_HEIGHT_TO_SIZE = 0.585
 
const double TRUETYPE_WIDTH_TO_SIZE = 0.585
 
const double TRUETYPE_THICK_PER_HEIGHT = 0.073
 
const double TRUETYPE_BOLD_THICK_MUL = 1.6
 
const long TRUETYPE_BOLD_MIN_WEIGHT = 700
 
static KEYWORD empty_keywords [1] = {}
 
static const char ACCEL_ASCII_KEYWORD [] = "ACCEL_ASCII"
 

Enumeration Type Documentation

◆ TTEXT_JUSTIFY

Enumerator
LowerLeft 
LowerCenter 
LowerRight 
UpperLeft 
UpperCenter 
UpperRight 
Left 
Center 
Right 

Definition at line 43 of file pcad2kicad_common.h.

Function Documentation

◆ CalculateTextLengthSize()

int PCAD2KICAD::CalculateTextLengthSize ( TTEXTVALUE aText)

Definition at line 509 of file pcad2kicad_common.cpp.

510{
511 return KiROUND( (double) aText->text.Len() *
512 (double) aText->textHeight * TEXT_WIDTH_TO_SIZE_AVERAGE );
513}
const double TEXT_WIDTH_TO_SIZE_AVERAGE
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:80

References KiROUND(), PCAD2KICAD::TTEXTVALUE::text, TEXT_WIDTH_TO_SIZE_AVERAGE, and PCAD2KICAD::TTEXTVALUE::textHeight.

Referenced by CorrectTextPosition().

◆ CorrectTextPosition()

void PCAD2KICAD::CorrectTextPosition ( TTEXTVALUE aValue)

Definition at line 516 of file pcad2kicad_common.cpp.

517{
518 int cm = aValue->mirror ? -1 : 1;
519 int cl = KiROUND( (double) CalculateTextLengthSize( aValue ) / 2.0 );
520 int ch = KiROUND( (double) aValue->textHeight / 2.0 );
521 int posX = 0;
522 int posY = 0;
523
524 if( aValue->justify == LowerLeft || aValue->justify == Left || aValue->justify == UpperLeft )
525 posX += cl * cm;
526 else if( aValue->justify == LowerRight || aValue->justify == Right ||
527 aValue->justify == UpperRight )
528 posX -= cl * cm;
529
530 if( aValue->justify == LowerLeft || aValue->justify == LowerCenter ||
531 aValue->justify == LowerRight )
532 posY -= ch;
533 else if( aValue->justify == UpperLeft || aValue->justify == UpperCenter ||
534 aValue->justify == UpperRight )
535 posY += ch;
536
537 RotatePoint( &posX, &posY, aValue->textRotation );
538
539 aValue->correctedPositionX = aValue->textPositionX + posX;
540 aValue->correctedPositionY = aValue->textPositionY + posY;
541}
int CalculateTextLengthSize(TTEXTVALUE *aText)
void RotatePoint(int *pX, int *pY, const EDA_ANGLE &aAngle)
Definition: trigo.cpp:183

References CalculateTextLengthSize(), PCAD2KICAD::TTEXTVALUE::correctedPositionX, PCAD2KICAD::TTEXTVALUE::correctedPositionY, PCAD2KICAD::TTEXTVALUE::justify, KiROUND(), Left, LowerCenter, LowerLeft, LowerRight, PCAD2KICAD::TTEXTVALUE::mirror, Right, RotatePoint(), PCAD2KICAD::TTEXTVALUE::textHeight, PCAD2KICAD::TTEXTVALUE::textPositionX, PCAD2KICAD::TTEXTVALUE::textPositionY, PCAD2KICAD::TTEXTVALUE::textRotation, UpperCenter, UpperLeft, and UpperRight.

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

◆ FindNode()

◆ FindNodeGetContent()

wxString PCAD2KICAD::FindNodeGetContent ( XNODE aChild,
const wxString &  aTag 
)

Definition at line 574 of file pcad2kicad_common.cpp.

575{
576 wxString str = wxEmptyString;
577
578 aChild = FindNode( aChild, aTag );
579
580 if( aChild )
581 {
582 str = aChild->GetNodeContent();
583 str.Trim( false );
584 str.Trim( true );
585 }
586
587 return str;
588}
XNODE * FindNode(XNODE *aChild, const wxString &aTag)

References FindNode().

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), PCAD2KICAD::PCB_PAD::Parse(), PCAD2KICAD::PCB_TEXT::Parse(), SetFontProperty(), and SetTextParameters().

◆ FindPinMap()

XNODE * PCAD2KICAD::FindPinMap ( XNODE aNode)

Definition at line 101 of file pcad2kicad_common.cpp.

102{
103 XNODE* result, * lNode;
104
105 result = nullptr;
106 lNode = FindNode( aNode, wxT( "attachedPattern" ) );
107
108 if( lNode )
109 result = FindNode( lNode, wxT( "padPinMap" ) );
110
111 return result;
112}
Hold an XML or S-expression element.
Definition: xnode.h:44

References FindNode().

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), and PCAD2KICAD::PCB_FOOTPRINT::Parse().

◆ GetAndCutWordWithMeasureUnits()

wxString PCAD2KICAD::GetAndCutWordWithMeasureUnits ( wxString *  aStr,
const wxString &  aDefaultMeasurementUnit 
)

Definition at line 185 of file pcad2kicad_common.cpp.

186{
187 wxString result;
188
189 aStr->Trim( false );
190 result = wxEmptyString;
191
192 // value
193 while( aStr->Len() > 0 && (*aStr)[0] != wxT( ' ' ) )
194 {
195 result += (*aStr)[0];
196 *aStr = aStr->Mid( 1 );
197 }
198
199 aStr->Trim( false );
200
201 // if there is also measurement unit
202 while( aStr->Len() > 0
203 && ( ( (*aStr)[0] >= wxT( 'a' ) && (*aStr)[0] <= wxT( 'z' ) )
204 || ( (*aStr)[0] >= wxT( 'A' ) && (*aStr)[0] <= wxT( 'Z' ) ) ) )
205 {
206 result += (*aStr)[0];
207 *aStr = aStr->Mid( 1 );
208 }
209
210 // and if not, add default....
211 if( result.Len() > 0
212 && ( result[result.Len() - 1] == wxT( '.' )
213 || result[result.Len() - 1] == wxT( ',' )
214 || (result[result.Len() - 1] >= wxT( '0' )
215 && result[result.Len() - 1] <= wxT( '9' ) ) ) )
216 {
217 result += aDefaultMeasurementUnit;
218 }
219
220 return result;
221}

Referenced by SetDoublePrecisionPosition(), SetHeight(), SetPosition(), and SetWidth().

◆ GetJustifyIdentificator()

TTEXT_JUSTIFY PCAD2KICAD::GetJustifyIdentificator ( const wxString &  aJustify)

Definition at line 302 of file pcad2kicad_common.cpp.

303{
304 TTEXT_JUSTIFY id;
305
306 if( aJustify.IsSameAs( wxT( "LowerCenter" ), false ) )
307 id = LowerCenter;
308 else if( aJustify.IsSameAs( wxT( "LowerRight" ), false ) )
309 id = LowerRight;
310 else if( aJustify.IsSameAs( wxT( "UpperLeft" ), false ) )
311 id = UpperLeft;
312 else if( aJustify.IsSameAs( wxT( "UpperCenter" ), false ) )
313 id = UpperCenter;
314 else if( aJustify.IsSameAs( wxT( "UpperRight" ), false ) )
315 id = UpperRight;
316 else if( aJustify.IsSameAs( wxT( "Left" ), false ) )
317 id = Left;
318 else if( aJustify.IsSameAs( wxT( "Center" ), false ) )
319 id = Center;
320 else if( aJustify.IsSameAs( wxT( "Right" ), false ) )
321 id = Right;
322 else
323 id = LowerLeft;
324
325 return id;
326}

References Center, Left, LowerCenter, LowerLeft, LowerRight, Right, UpperCenter, UpperLeft, and UpperRight.

Referenced by PCAD2KICAD::PCB_TEXT::Parse(), and SetTextParameters().

◆ GetWord()

wxString PCAD2KICAD::GetWord ( wxString *  aStr)

Definition at line 56 of file pcad2kicad_common.cpp.

57{
58 wxString result = wxEmptyString;
59
60 *aStr = aStr->Trim( false );
61
62 if( aStr->Len() == 0 )
63 return result;
64
65 if( (*aStr)[0] == wxT( '"' ) )
66 {
67 result += (*aStr)[0];
68 *aStr = aStr->Mid( 1 ); // remove Frot apostrofe
69
70 while( aStr->Len() > 0 && (*aStr)[0] != wxT( '"' ) )
71 {
72 result += (*aStr)[0];
73 *aStr = aStr->Mid( 1 );
74 }
75
76 if( aStr->Len() > 0 && (*aStr)[0] == wxT( '"' ) )
77 {
78 result += (*aStr)[0];
79 *aStr = aStr->Mid( 1 ); // remove ending apostrophe
80 }
81 }
82 else
83 {
84 while( aStr->Len() > 0
85 && !( (*aStr)[0] == wxT( ' ' )
86 || (*aStr)[0] == wxT( '(' )
87 || (*aStr)[0] == wxT( ')' ) ) )
88 {
89 result += (*aStr)[0];
90 *aStr = aStr->Mid( 1 );
91 }
92 }
93
94 result.Trim( true );
95 result.Trim( false );
96
97 return result;
98}

◆ InitTTextValue()

void PCAD2KICAD::InitTTextValue ( TTEXTVALUE aTextValue)

Definition at line 591 of file pcad2kicad_common.cpp.

592{
593 aTextValue->text = wxEmptyString;
594 aTextValue->textPositionX = 0;
595 aTextValue->textPositionY = 0;
596 aTextValue->textRotation = ANGLE_0;
597 aTextValue->textHeight = 0;
598 aTextValue->textstrokeWidth = 0;
599 aTextValue->textIsVisible = 0;
600 aTextValue->mirror = 0;
601 aTextValue->textUnit = 0;
602 aTextValue->correctedPositionX = 0;
603 aTextValue->correctedPositionY = 0;
604 aTextValue->justify = LowerLeft;
605 aTextValue->isBold = false;
606 aTextValue->isItalic = false;
607 aTextValue->isTrueType = false;
608}
static constexpr EDA_ANGLE & ANGLE_0
Definition: eda_angle.h:412

References ANGLE_0, PCAD2KICAD::TTEXTVALUE::correctedPositionX, PCAD2KICAD::TTEXTVALUE::correctedPositionY, PCAD2KICAD::TTEXTVALUE::isBold, PCAD2KICAD::TTEXTVALUE::isItalic, PCAD2KICAD::TTEXTVALUE::isTrueType, PCAD2KICAD::TTEXTVALUE::justify, LowerLeft, PCAD2KICAD::TTEXTVALUE::mirror, PCAD2KICAD::TTEXTVALUE::text, PCAD2KICAD::TTEXTVALUE::textHeight, PCAD2KICAD::TTEXTVALUE::textIsVisible, PCAD2KICAD::TTEXTVALUE::textPositionX, PCAD2KICAD::TTEXTVALUE::textPositionY, PCAD2KICAD::TTEXTVALUE::textRotation, PCAD2KICAD::TTEXTVALUE::textstrokeWidth, and PCAD2KICAD::TTEXTVALUE::textUnit.

Referenced by PCAD2KICAD::PCB_COMPONENT::PCB_COMPONENT(), and PCAD2KICAD::PCB_FOOTPRINT::PCB_FOOTPRINT().

◆ LoadInputFile()

void PCAD2KICAD::LoadInputFile ( const wxString &  aFileName,
wxXmlDocument *  aXmlDoc 
)

Definition at line 41 of file s_expr_loader.cpp.

42{
43 char line[sizeof( ACCEL_ASCII_KEYWORD )];
44 int tok;
45 XNODE* iNode = nullptr, *cNode = nullptr;
46 wxString str, propValue, content;
47 wxCSConv conv( wxT( "windows-1251" ) );
48
49 FILE* fp = wxFopen( aFileName, wxT( "rt" ) );
50
51 if( !fp )
52 THROW_IO_ERROR( wxT( "Unable to open file: " ) + aFileName );
53
54 // check file format
55 if( !fgets( line, sizeof( line ), fp )
56 // first line starts with "ACCEL_ASCII" with optional stuff on same line after that.
57 || memcmp( line, ACCEL_ASCII_KEYWORD, sizeof(ACCEL_ASCII_KEYWORD)-1 ) )
58 THROW_IO_ERROR( wxT( "Unknown file type" ) );
59
60 // rewind the file
61 fseek( fp, 0, SEEK_SET );
62
63 // lexer now owns fp, will close on exception or return
64 DSNLEXER lexer( empty_keywords, 0, nullptr, fp, aFileName );
65
66 iNode = new XNODE( wxXML_ELEMENT_NODE, wxT( "www.lura.sk" ) );
67
68 while( ( tok = lexer.NextTok() ) != DSN_EOF )
69 {
70 if( tok == DSN_RIGHT )
71 {
72 iNode = iNode->GetParent();
73 }
74 else if( tok == DSN_LEFT )
75 {
76 tok = lexer.NextTok();
77 str = wxEmptyString;
78 cNode = new XNODE( wxXML_ELEMENT_NODE, wxString( lexer.CurText(), conv ) );
79 iNode->AddChild( cNode );
80 iNode = cNode;
81 }
82 else if( cNode )
83 {
84 str = wxString( lexer.CurText(), conv );
85
86 if( tok == DSN_STRING )
87 {
88 // update attribute
89 if( iNode->GetAttribute( wxT( "Name" ), &propValue ) )
90 {
91 iNode->DeleteAttribute( wxT( "Name" ) );
92 iNode->AddAttribute( wxT( "Name" ), propValue + wxT( ' ' ) + str );
93 }
94 else
95 {
96 iNode->AddAttribute( wxT( "Name" ), str );
97 }
98 }
99 else if( str != wxEmptyString )
100 {
101 // update node content
102 content = cNode->GetNodeContent() + wxT( ' ' ) + str;
103
104 if( cNode->GetChildren() )
105 cNode->GetChildren()->SetContent( content );
106 else
107 cNode->AddChild( new wxXmlNode( wxXML_TEXT_NODE, wxEmptyString, content ) );
108 }
109 }
110 }
111
112 if( iNode )
113 {
114 aXmlDoc->SetRoot( iNode );
115 //aXmlDoc->Save( wxT( "test.xml" ) );
116 }
117}
Implement a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:79
XNODE * GetParent() const
Definition: xnode.h:72
static const KEYWORD empty_keywords[1]
Definition: dsnlexer.cpp:110
@ DSN_LEFT
Definition: dsnlexer.h:67
@ DSN_RIGHT
Definition: dsnlexer.h:66
@ DSN_STRING
Definition: dsnlexer.h:68
@ DSN_EOF
Definition: dsnlexer.h:69
#define THROW_IO_ERROR(msg)
Definition: ki_exception.h:38
static const char ACCEL_ASCII_KEYWORD[]

References ACCEL_ASCII_KEYWORD, DSNLEXER::CurText(), DSN_EOF, DSN_LEFT, DSN_RIGHT, DSN_STRING, empty_keywords, XNODE::GetChildren(), XNODE::GetParent(), DSNLEXER::NextTok(), and THROW_IO_ERROR.

Referenced by PCAD_PLUGIN::Load().

◆ SetDoublePrecisionPosition()

void PCAD2KICAD::SetDoublePrecisionPosition ( const wxString &  aStr,
const wxString &  aDefaultMeasurementUnit,
double *  aX,
double *  aY,
const wxString &  aActualConversion 
)

Definition at line 288 of file pcad2kicad_common.cpp.

290{
291 wxString tmp = aStr;
292
294 GetAndCutWordWithMeasureUnits( &tmp, aDefaultMeasurementUnit ), wxT( 'X' ),
295 aActualConversion );
297 GetAndCutWordWithMeasureUnits( &tmp, aDefaultMeasurementUnit ), wxT( 'Y' ),
298 aActualConversion );
299}
double StrToDoublePrecisionUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)

References GetAndCutWordWithMeasureUnits(), and StrToDoublePrecisionUnits().

Referenced by PCAD2KICAD::PCB_POLYGON::FormPolygon().

◆ SetFontProperty()

void PCAD2KICAD::SetFontProperty ( XNODE aNode,
TTEXTVALUE aTextValue,
const wxString &  aDefaultMeasurementUnit,
const wxString &  aActualConversion 
)

Definition at line 378 of file pcad2kicad_common.cpp.

380{
381 wxString n, propValue;
382
383 aNode->GetAttribute( wxT( "Name" ), &n );
384
385 while( aNode->GetName() != wxT( "www.lura.sk" ) )
386 aNode = aNode->GetParent();
387
388 aNode = FindNode( aNode, wxT( "library" ) );
389
390 if( aNode )
391 aNode = FindNode( aNode, wxT( "textStyleDef" ) );
392
393 while( aNode )
394 {
395 aNode->GetAttribute( wxT( "Name" ), &propValue );
396 propValue.Trim( false );
397 propValue.Trim( true );
398
399 if( propValue == n )
400 break;
401
402 aNode = aNode->GetNext();
403 }
404
405 if( aNode )
406 {
407 wxString fontType;
408
409 propValue = FindNodeGetContent( aNode, wxT( "textStyleDisplayTType" ) );
410 aTextValue->isTrueType = ( propValue.IsSameAs( wxT( "True" ), false ) );
411
412 aNode = FindNode( aNode, wxT( "font" ) );
413 fontType = FindNodeGetContent( aNode, wxT( "fontType" ) );
414
415 if( ( aTextValue->isTrueType && !fontType.IsSameAs( wxT( "TrueType" ), false ) ) ||
416 ( !aTextValue->isTrueType && !fontType.IsSameAs( wxT( "Stroke" ), false ) ) )
417 aNode = aNode->GetNext();
418
419 if( aNode )
420 {
421 if( aTextValue->isTrueType )
422 {
423 propValue = FindNodeGetContent( aNode, wxT( "fontItalic" ) );
424 aTextValue->isItalic = propValue.IsSameAs( wxT( "True" ), false );
425
426 propValue = FindNodeGetContent( aNode, wxT( "fontWeight" ) );
427
428 if( propValue != wxEmptyString )
429 {
430 long fontWeight;
431
432 propValue.ToLong( &fontWeight );
433 aTextValue->isBold = ( fontWeight >= TRUETYPE_BOLD_MIN_WEIGHT );
434 }
435 }
436
437 XNODE* lNode;
438
439 lNode = FindNode( aNode, wxT( "fontHeight" ) );
440
441 if( lNode )
442 SetHeight( lNode->GetNodeContent(), aDefaultMeasurementUnit,
443 &aTextValue->textHeight, aActualConversion );
444
445 if( aTextValue->isTrueType )
446 {
447 aTextValue->textstrokeWidth = TRUETYPE_THICK_PER_HEIGHT * aTextValue->textHeight;
448
449 if( aTextValue->isBold )
451 }
452 else
453 {
454 lNode = FindNode( aNode, wxT( "strokeWidth" ) );
455
456 if( lNode )
457 SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit,
458 &aTextValue->textstrokeWidth, aActualConversion );
459 }
460 }
461 }
462}
void SetWidth(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
void SetHeight(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aHeight, const wxString &aActualConversion)
const double TRUETYPE_THICK_PER_HEIGHT
const double TRUETYPE_BOLD_THICK_MUL
const long TRUETYPE_BOLD_MIN_WEIGHT
wxString FindNodeGetContent(XNODE *aChild, const wxString &aTag)

References FindNode(), FindNodeGetContent(), XNODE::GetNext(), XNODE::GetParent(), PCAD2KICAD::TTEXTVALUE::isBold, PCAD2KICAD::TTEXTVALUE::isItalic, PCAD2KICAD::TTEXTVALUE::isTrueType, SetHeight(), SetWidth(), PCAD2KICAD::TTEXTVALUE::textHeight, PCAD2KICAD::TTEXTVALUE::textstrokeWidth, TRUETYPE_BOLD_MIN_WEIGHT, TRUETYPE_BOLD_THICK_MUL, and TRUETYPE_THICK_PER_HEIGHT.

Referenced by PCAD2KICAD::PCB_FOOTPRINT::DoLayerContentsObjects(), PCAD2KICAD::PCB_TEXT::Parse(), and SetTextParameters().

◆ SetHeight()

void PCAD2KICAD::SetHeight ( const wxString &  aStr,
const wxString &  aDefaultMeasurementUnit,
int *  aHeight,
const wxString &  aActualConversion 
)

Definition at line 266 of file pcad2kicad_common.cpp.

268{
269 wxString tmp = aStr;
270
271 *aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &tmp, aDefaultMeasurementUnit ),
272 wxT( ' ' ), aActualConversion );
273}
int StrToIntUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)

References GetAndCutWordWithMeasureUnits(), and StrToIntUnits().

Referenced by SetFontProperty().

◆ SetPosition()

void PCAD2KICAD::SetPosition ( const wxString &  aStr,
const wxString &  aDefaultMeasurementUnit,
int *  aX,
int *  aY,
const wxString &  aActualConversion 
)

◆ SetTextJustify()

void PCAD2KICAD::SetTextJustify ( EDA_TEXT aText,
TTEXT_JUSTIFY  aJustify 
)

Definition at line 465 of file pcad2kicad_common.cpp.

466{
467 switch( aJustify )
468 {
469 case LowerLeft:
472 break;
473 case LowerCenter:
476 break;
477 case LowerRight:
480 break;
481 case UpperLeft:
484 break;
485 case UpperCenter:
488 break;
489 case UpperRight:
492 break;
493 case Left:
496 break;
497 case Center:
500 break;
501 case Right:
504 break;
505 }
506}
void SetVertJustify(GR_TEXT_V_ALIGN_T aType)
Definition: eda_text.cpp:248
void SetHorizJustify(GR_TEXT_H_ALIGN_T aType)
Definition: eda_text.cpp:240
@ GR_TEXT_H_ALIGN_CENTER
@ GR_TEXT_H_ALIGN_RIGHT
@ GR_TEXT_H_ALIGN_LEFT
@ GR_TEXT_V_ALIGN_BOTTOM
@ GR_TEXT_V_ALIGN_CENTER
@ GR_TEXT_V_ALIGN_TOP

References Center, GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_CENTER, GR_TEXT_V_ALIGN_TOP, Left, LowerCenter, LowerLeft, LowerRight, Right, EDA_TEXT::SetHorizJustify(), EDA_TEXT::SetVertJustify(), UpperCenter, UpperLeft, and UpperRight.

Referenced by PCAD2KICAD::PCB_TEXT::AddToBoard().

◆ SetTextParameters()

void PCAD2KICAD::SetTextParameters ( XNODE aNode,
TTEXTVALUE aTextValue,
const wxString &  aDefaultMeasurementUnit,
const wxString &  aActualConversion 
)

Definition at line 329 of file pcad2kicad_common.cpp.

331{
332 XNODE* tNode;
333 wxString str;
334
335 tNode = FindNode( aNode, wxT( "pt" ) );
336
337 if( tNode )
338 SetPosition( tNode->GetNodeContent(), aDefaultMeasurementUnit, &aTextValue->textPositionX,
339 &aTextValue->textPositionY, aActualConversion );
340
341 tNode = FindNode( aNode, wxT( "rotation" ) );
342
343 if( tNode )
344 {
345 str = tNode->GetNodeContent();
346 str.Trim( false );
348 }
349 else
350 {
351 aTextValue->textRotation = ANGLE_0;
352 }
353
354 str = FindNodeGetContent( aNode, wxT( "isVisible" ) );
355
356 if( str.IsSameAs( wxT( "True" ), false ) )
357 aTextValue->textIsVisible = 1;
358 else
359 aTextValue->textIsVisible = 0;
360
361 str = FindNodeGetContent( aNode, wxT( "justify" ) );
362 aTextValue->justify = GetJustifyIdentificator( str );
363
364 str = FindNodeGetContent( aNode, wxT( "isFlipped" ) );
365
366 if( str.IsSameAs( wxT( "True" ), false ) )
367 aTextValue->mirror = 1;
368 else
369 aTextValue->mirror = 0;
370
371 tNode = FindNode( aNode, wxT( "textStyleRef" ) );
372
373 if( tNode )
374 SetFontProperty( tNode, aTextValue, aDefaultMeasurementUnit, aActualConversion );
375}
@ TENTHS_OF_A_DEGREE_T
Definition: eda_angle.h:30
int StrToInt1Units(const wxString &aStr)
void SetPosition(const wxString &aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
TTEXT_JUSTIFY GetJustifyIdentificator(const wxString &aJustify)
void SetFontProperty(XNODE *aNode, TTEXTVALUE *aTextValue, const wxString &aDefaultMeasurementUnit, const wxString &aActualConversion)

References ANGLE_0, FindNode(), FindNodeGetContent(), GetJustifyIdentificator(), PCAD2KICAD::TTEXTVALUE::justify, PCAD2KICAD::TTEXTVALUE::mirror, SetFontProperty(), SetPosition(), StrToInt1Units(), TENTHS_OF_A_DEGREE_T, PCAD2KICAD::TTEXTVALUE::textIsVisible, PCAD2KICAD::TTEXTVALUE::textPositionX, PCAD2KICAD::TTEXTVALUE::textPositionY, and PCAD2KICAD::TTEXTVALUE::textRotation.

Referenced by PCAD2KICAD::PCB::SetTextProperty().

◆ SetTextSizeFromStrokeFontHeight()

void PCAD2KICAD::SetTextSizeFromStrokeFontHeight ( EDA_TEXT aText,
int  aTextHeight 
)

Definition at line 544 of file pcad2kicad_common.cpp.

545{
546 aText->SetTextSize( wxSize( KiROUND( aTextHeight * STROKE_WIDTH_TO_SIZE ),
547 KiROUND( aTextHeight * STROKE_HEIGHT_TO_SIZE ) ) );
548}
void SetTextSize(const VECTOR2I &aNewSize)
Definition: eda_text.cpp:347
const double STROKE_WIDTH_TO_SIZE
const double STROKE_HEIGHT_TO_SIZE

References KiROUND(), EDA_TEXT::SetTextSize(), STROKE_HEIGHT_TO_SIZE, and STROKE_WIDTH_TO_SIZE.

Referenced by PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), and PCAD2KICAD::PCB_TEXT::AddToBoard().

◆ SetTextSizeFromTrueTypeFontHeight()

void PCAD2KICAD::SetTextSizeFromTrueTypeFontHeight ( EDA_TEXT aText,
int  aTextHeight 
)

Definition at line 551 of file pcad2kicad_common.cpp.

552{
553 aText->SetTextSize( wxSize( KiROUND( aTextHeight * TRUETYPE_WIDTH_TO_SIZE ),
554 KiROUND( aTextHeight * TRUETYPE_HEIGHT_TO_SIZE ) ) );
555}
const double TRUETYPE_HEIGHT_TO_SIZE
const double TRUETYPE_WIDTH_TO_SIZE

References KiROUND(), EDA_TEXT::SetTextSize(), TRUETYPE_HEIGHT_TO_SIZE, and TRUETYPE_WIDTH_TO_SIZE.

Referenced by PCAD2KICAD::PCB_FOOTPRINT::AddToBoard(), and PCAD2KICAD::PCB_TEXT::AddToBoard().

◆ SetWidth()

void PCAD2KICAD::SetWidth ( const wxString &  aStr,
const wxString &  aDefaultMeasurementUnit,
int *  aWidth,
const wxString &  aActualConversion 
)

◆ StrToDoublePrecisionUnits()

double PCAD2KICAD::StrToDoublePrecisionUnits ( const wxString &  aStr,
char  aAxe,
const wxString &  aActualConversion 
)

Definition at line 115 of file pcad2kicad_common.cpp.

117{
118 wxString ls;
119 double i;
120 char u;
121
122 ls = aStr;
123 ls.Trim( true );
124 ls.Trim( false );
125
126 if( ls.Len() > 0 )
127 {
128 u = ls[ls.Len() - 1];
129
130 while( ls.Len() > 0
131 && !( ls[ls.Len() - 1] == wxT( '.' )
132 || ls[ls.Len() - 1] == wxT( ',' )
133 || (ls[ls.Len() - 1] >= wxT( '0' ) && ls[ls.Len() - 1] <= wxT( '9' ) ) ) )
134 {
135 ls = ls.Left( ls.Len() - 1 );
136 }
137
138 while( ls.Len() > 0
139 && !( ls[0] == wxT( '-' )
140 || ls[0] == wxT( '+' )
141 || ls[0] == wxT( '.' )
142 || ls[0] == wxT( ',' )
143 || (ls[0] >= wxT( '0' ) && ls[0] <= wxT( '9' ) ) ) )
144 {
145 ls = ls.Mid( 1 );
146 }
147
148 if( u == wxT( 'm' ) )
149 {
150 ls.ToCDouble( &i );
151
152#ifdef PCAD2KICAD_SCALE_SCH_TO_INCH_GRID
153 if( aActualConversion == wxT( "SCH" )
154 || aActualConversion == wxT( "SCHLIB" ) )
155 i = i * (0.0254 / 0.025);
156#endif
157
158 i = pcbIUScale.mmToIU( i );
159 }
160 else
161 {
162 ls.ToCDouble( &i );
164 }
165 }
166 else
167 {
168 i = 0.0;
169 }
170
171 if( ( aActualConversion == wxT( "PCB" ) || aActualConversion == wxT( "SCH" ) )
172 && aAxe == wxT( 'Y' ) )
173 return -i;
174 else
175 return i; // Y axe is mirrored compared to P-Cad
176}
constexpr EDA_IU_SCALE pcbIUScale
Definition: base_units.h:109
const double IU_PER_MILS
Definition: base_units.h:78
constexpr int mmToIU(double mm) const
Definition: base_units.h:89

References EDA_IU_SCALE::IU_PER_MILS, EDA_IU_SCALE::mmToIU(), and pcbIUScale.

Referenced by SetDoublePrecisionPosition(), and StrToIntUnits().

◆ StrToInt1Units()

int PCAD2KICAD::StrToInt1Units ( const wxString &  aStr)

Definition at line 224 of file pcad2kicad_common.cpp.

225{
226 double num, precision = 10;
227
228 aStr.ToCDouble( &num );
229 return KiROUND( num * precision );
230}

References KiROUND().

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), PCAD2KICAD::PCB_PAD::Parse(), PCAD2KICAD::PCB_ARC::Parse(), PCAD2KICAD::PCB_TEXT::Parse(), and SetTextParameters().

◆ StrToIntUnits()

int PCAD2KICAD::StrToIntUnits ( const wxString &  aStr,
char  aAxe,
const wxString &  aActualConversion 
)

Definition at line 179 of file pcad2kicad_common.cpp.

180{
181 return KiROUND( StrToDoublePrecisionUnits( aStr, aAxe, aActualConversion ) );
182}

References KiROUND(), and StrToDoublePrecisionUnits().

Referenced by SetHeight(), SetPosition(), and SetWidth().

◆ ValidateName()

wxString PCAD2KICAD::ValidateName ( const wxString &  aName)

Definition at line 233 of file pcad2kicad_common.cpp.

234{
235 wxString retv = aName;
236 retv.Replace( wxT( " " ), wxT( "_" ) );
237
238 return retv;
239}

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), PCAD2KICAD::PCB_FOOTPRINT::FindModulePatternDefName(), and PCAD2KICAD::PCB_FOOTPRINT::FindPatternMultilayerSection().

◆ ValidateReference()

wxString PCAD2KICAD::ValidateReference ( const wxString &  aRef)

Definition at line 242 of file pcad2kicad_common.cpp.

243{
244 wxRegEx reRef;
245 reRef.Compile( wxT( "^[[:digit:]][[:digit:]]*$" ) );
246
247 wxString retv = aRef;
248
249 if( reRef.Matches( retv ) )
250 retv.Prepend( wxT( '.' ) );
251
252 return retv;
253}

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

◆ WX_DEFINE_ARRAY() [1/4]

PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_COMPONENT ,
PCB_COMPONENTS_ARRAY   
)

◆ WX_DEFINE_ARRAY() [2/4]

PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_NET ,
PCB_NETS_ARRAY   
)

◆ WX_DEFINE_ARRAY() [3/4]

PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_NET_NODE ,
PCB_NET_NODES_ARRAY   
)

◆ WX_DEFINE_ARRAY() [4/4]

PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_PAD_SHAPE ,
PCB_PAD_SHAPES_ARRAY   
)

Variable Documentation

◆ ACCEL_ASCII_KEYWORD

const char PCAD2KICAD::ACCEL_ASCII_KEYWORD[] = "ACCEL_ASCII"
static

Definition at line 38 of file s_expr_loader.cpp.

Referenced by LoadInputFile().

◆ empty_keywords

KEYWORD PCAD2KICAD::empty_keywords[1] = {}
static

Definition at line 37 of file s_expr_loader.cpp.

Referenced by LoadInputFile().

◆ STROKE_HEIGHT_TO_SIZE

const double PCAD2KICAD::STROKE_HEIGHT_TO_SIZE = 0.656

Definition at line 45 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromStrokeFontHeight().

◆ STROKE_WIDTH_TO_SIZE

const double PCAD2KICAD::STROKE_WIDTH_TO_SIZE = 0.69

Definition at line 46 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromStrokeFontHeight().

◆ TEXT_WIDTH_TO_SIZE_AVERAGE

const double PCAD2KICAD::TEXT_WIDTH_TO_SIZE_AVERAGE = 0.5

Definition at line 42 of file pcad2kicad_common.cpp.

Referenced by CalculateTextLengthSize().

◆ TRUETYPE_BOLD_MIN_WEIGHT

const long PCAD2KICAD::TRUETYPE_BOLD_MIN_WEIGHT = 700

Definition at line 53 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_BOLD_THICK_MUL

const double PCAD2KICAD::TRUETYPE_BOLD_THICK_MUL = 1.6

Definition at line 52 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_HEIGHT_TO_SIZE

const double PCAD2KICAD::TRUETYPE_HEIGHT_TO_SIZE = 0.585

Definition at line 49 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromTrueTypeFontHeight().

◆ TRUETYPE_THICK_PER_HEIGHT

const double PCAD2KICAD::TRUETYPE_THICK_PER_HEIGHT = 0.073

Definition at line 51 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_WIDTH_TO_SIZE

const double PCAD2KICAD::TRUETYPE_WIDTH_TO_SIZE = 0.585

Definition at line 50 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromTrueTypeFontHeight().