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 510 of file pcad2kicad_common.cpp.

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

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 517 of file pcad2kicad_common.cpp.

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

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()

XNODE * PCAD2KICAD::FindNode ( XNODE aChild,
const wxString &  aTag 
)

◆ FindNodeGetContent()

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

Definition at line 575 of file pcad2kicad_common.cpp.

576 {
577  wxString str = wxEmptyString;
578 
579  aChild = FindNode( aChild, aTag );
580 
581  if( aChild )
582  {
583  str = aChild->GetNodeContent();
584  str.Trim( false );
585  str.Trim( true );
586  }
587 
588  return str;
589 }
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 102 of file pcad2kicad_common.cpp.

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

References FindNode().

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

◆ GetAndCutWordWithMeasureUnits()

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

Definition at line 186 of file pcad2kicad_common.cpp.

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

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

◆ GetJustifyIdentificator()

TTEXT_JUSTIFY PCAD2KICAD::GetJustifyIdentificator ( const wxString &  aJustify)

Definition at line 303 of file pcad2kicad_common.cpp.

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

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 57 of file pcad2kicad_common.cpp.

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

◆ InitTTextValue()

void PCAD2KICAD::InitTTextValue ( TTEXTVALUE aTextValue)

Definition at line 592 of file pcad2kicad_common.cpp.

593 {
594  aTextValue->text = wxEmptyString;
595  aTextValue->textPositionX = 0;
596  aTextValue->textPositionY = 0;
597  aTextValue->textRotation = 0;
598  aTextValue->textHeight = 0;
599  aTextValue->textstrokeWidth = 0;
600  aTextValue->textIsVisible = 0;
601  aTextValue->mirror = 0;
602  aTextValue->textUnit = 0;
603  aTextValue->correctedPositionX = 0;
604  aTextValue->correctedPositionY = 0;
605  aTextValue->justify = LowerLeft;
606  aTextValue->isBold = false;
607  aTextValue->isItalic = false;
608  aTextValue->isTrueType = false;
609 }

References 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 40 of file s_expr_loader.cpp.

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

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 289 of file pcad2kicad_common.cpp.

291 {
292  wxString tmp = aStr;
293 
295  GetAndCutWordWithMeasureUnits( &tmp, aDefaultMeasurementUnit ), wxT( 'X' ),
296  aActualConversion );
298  GetAndCutWordWithMeasureUnits( &tmp, aDefaultMeasurementUnit ), wxT( 'Y' ),
299  aActualConversion );
300 }
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 379 of file pcad2kicad_common.cpp.

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

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 267 of file pcad2kicad_common.cpp.

269 {
270  wxString tmp = aStr;
271 
272  *aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &tmp, aDefaultMeasurementUnit ),
273  wxT( ' ' ), aActualConversion );
274 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)
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 
)

Definition at line 277 of file pcad2kicad_common.cpp.

279 {
280  wxString tmp = aStr;
281 
282  *aX = StrToIntUnits( GetAndCutWordWithMeasureUnits( &tmp, aDefaultMeasurementUnit ),
283  wxT( 'X' ), aActualConversion );
284  *aY = StrToIntUnits( GetAndCutWordWithMeasureUnits( &tmp, aDefaultMeasurementUnit ),
285  wxT( 'Y' ), aActualConversion );
286 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)
int StrToIntUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)

References GetAndCutWordWithMeasureUnits(), and StrToIntUnits().

Referenced by PCAD2KICAD::PCB::DoPCBComponents(), PCAD2KICAD::PCB::GetBoardOutline(), STATUS_POPUP::Move(), PCAD2KICAD::PCB_PAD_SHAPE::Parse(), PCAD2KICAD::PCB_VIA::Parse(), PCAD2KICAD::PCB_ARC::Parse(), PCAD2KICAD::PCB_PAD::Parse(), PCAD2KICAD::PCB_LINE::Parse(), PCAD2KICAD::PCB_TEXT::Parse(), DIALOG_SHIM::SetPosition(), and SetTextParameters().

◆ SetTextJustify()

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

Definition at line 466 of file pcad2kicad_common.cpp.

467 {
468  switch( aJustify )
469  {
470  case LowerLeft:
473  break;
474  case LowerCenter:
477  break;
478  case LowerRight:
481  break;
482  case UpperLeft:
485  break;
486  case UpperCenter:
489  break;
490  case UpperRight:
493  break;
494  case Left:
497  break;
498  case Center:
501  break;
502  case Right:
505  break;
506  }
507 }
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:202
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:201

References Center, GR_TEXT_HJUSTIFY_CENTER, GR_TEXT_HJUSTIFY_LEFT, GR_TEXT_HJUSTIFY_RIGHT, GR_TEXT_VJUSTIFY_BOTTOM, GR_TEXT_VJUSTIFY_CENTER, GR_TEXT_VJUSTIFY_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 330 of file pcad2kicad_common.cpp.

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

References FindNode(), FindNodeGetContent(), GetJustifyIdentificator(), PCAD2KICAD::TTEXTVALUE::justify, PCAD2KICAD::TTEXTVALUE::mirror, SetFontProperty(), SetPosition(), StrToInt1Units(), 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 545 of file pcad2kicad_common.cpp.

546 {
547  aText->SetTextSize( wxSize( KiROUND( aTextHeight * STROKE_WIDTH_TO_SIZE ),
548  KiROUND( aTextHeight * STROKE_HEIGHT_TO_SIZE ) ) );
549 }
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
const double STROKE_WIDTH_TO_SIZE
const double STROKE_HEIGHT_TO_SIZE
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

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

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

◆ SetTextSizeFromTrueTypeFontHeight()

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

Definition at line 552 of file pcad2kicad_common.cpp.

553 {
554  aText->SetTextSize( wxSize( KiROUND( aTextHeight * TRUETYPE_WIDTH_TO_SIZE ),
555  KiROUND( aTextHeight * TRUETYPE_HEIGHT_TO_SIZE ) ) );
556 }
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:237
const double TRUETYPE_WIDTH_TO_SIZE
const double TRUETYPE_HEIGHT_TO_SIZE
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

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

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

◆ SetWidth()

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

Definition at line 257 of file pcad2kicad_common.cpp.

259 {
260  wxString tmp = aStr;
261 
262  *aWidth = StrToIntUnits( GetAndCutWordWithMeasureUnits( &tmp, aDefaultMeasurementUnit ),
263  wxT( ' ' ), aActualConversion );
264 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)
int StrToIntUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)

References GetAndCutWordWithMeasureUnits(), and StrToIntUnits().

Referenced by PCAD2KICAD::PCB_PLANE::Parse(), PCAD2KICAD::PCB_VIA_SHAPE::Parse(), PCAD2KICAD::PCB_COPPER_POUR::Parse(), PCAD2KICAD::PCB_PAD_SHAPE::Parse(), PCAD2KICAD::PCB_VIA::Parse(), PCAD2KICAD::PCB_PAD::Parse(), PCAD2KICAD::PCB_ARC::Parse(), PCAD2KICAD::PCB_LINE::Parse(), and SetFontProperty().

◆ StrToDoublePrecisionUnits()

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

Definition at line 116 of file pcad2kicad_common.cpp.

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

References Millimeter2iu().

Referenced by SetDoublePrecisionPosition(), and StrToIntUnits().

◆ StrToInt1Units()

int PCAD2KICAD::StrToInt1Units ( const wxString &  aStr)

Definition at line 225 of file pcad2kicad_common.cpp.

226 {
227  double num, precision = 10;
228 
229  aStr.ToCDouble( &num );
230  return KiROUND( num * precision );
231 }
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

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 180 of file pcad2kicad_common.cpp.

181 {
182  return KiROUND( StrToDoublePrecisionUnits( aStr, aAxe, aActualConversion ) );
183 }
double StrToDoublePrecisionUnits(const wxString &aStr, char aAxe, 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:73

References KiROUND(), and StrToDoublePrecisionUnits().

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

◆ ValidateName()

wxString PCAD2KICAD::ValidateName ( const wxString &  aName)

Definition at line 234 of file pcad2kicad_common.cpp.

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

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

◆ ValidateReference()

wxString PCAD2KICAD::ValidateReference ( const wxString &  aRef)

Definition at line 243 of file pcad2kicad_common.cpp.

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

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 37 of file s_expr_loader.cpp.

Referenced by LoadInputFile().

◆ empty_keywords

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

Definition at line 36 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 46 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromStrokeFontHeight().

◆ STROKE_WIDTH_TO_SIZE

const double PCAD2KICAD::STROKE_WIDTH_TO_SIZE = 0.69

Definition at line 47 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 43 of file pcad2kicad_common.cpp.

Referenced by CalculateTextLengthSize().

◆ TRUETYPE_BOLD_MIN_WEIGHT

const long PCAD2KICAD::TRUETYPE_BOLD_MIN_WEIGHT = 700

Definition at line 54 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_BOLD_THICK_MUL

const double PCAD2KICAD::TRUETYPE_BOLD_THICK_MUL = 1.6

Definition at line 53 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_HEIGHT_TO_SIZE

const double PCAD2KICAD::TRUETYPE_HEIGHT_TO_SIZE = 0.585

Definition at line 50 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromTrueTypeFontHeight().

◆ TRUETYPE_THICK_PER_HEIGHT

const double PCAD2KICAD::TRUETYPE_THICK_PER_HEIGHT = 0.073

Definition at line 52 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_WIDTH_TO_SIZE

const double PCAD2KICAD::TRUETYPE_WIDTH_TO_SIZE = 0.585

Definition at line 51 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromTrueTypeFontHeight().