KiCad PCB EDA Suite
PCAD2KICAD Namespace Reference

Classes

struct  _TTEXTVALUE
 
class  PCB
 
class  PCB_ARC
 
class  PCB_CALLBACKS
 
class  PCB_COMPONENT
 
class  PCB_COPPER_POUR
 
class  PCB_CUTOUT
 
class  PCB_KEEPOUT
 
class  PCB_LINE
 
class  PCB_MODULE
 
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
 

Typedefs

typedef struct PCAD2KICAD::_TTEXTVALUE 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 (wxString aName)
 
wxString ValidateReference (wxString aRef)
 
void SetWidth (wxString aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
 
void SetHeight (wxString aStr, const wxString &aDefaultMeasurementUnit, int *aHeight, const wxString &aActualConversion)
 
void SetPosition (wxString aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
 
void SetDoublePrecisionPosition (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 (wxRealPoint *, VERTICES_ARRAY)
 
 WX_DEFINE_ARRAY (PCB_NET_NODE *, PCB_NET_NODES_ARRAY)
 
 WX_DEFINE_ARRAY (PCB_NET *, PCB_NETS_ARRAY)
 
 WX_DEFINE_ARRAY (PCB_PAD_SHAPE *, PCB_PAD_SHAPES_ARRAY)
 
 WX_DEFINE_ARRAY (VERTICES_ARRAY *, ISLANDS_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"
 

Typedef Documentation

◆ TTEXTVALUE

Enumeration Type Documentation

◆ TTEXT_JUSTIFY

Enumerator
LowerLeft 
LowerCenter 
LowerRight 
UpperLeft 
UpperCenter 
UpperRight 
Left 
Center 
Right 

Definition at line 44 of file pcad2kicad_common.h.

Function Documentation

◆ CalculateTextLengthSize()

int PCAD2KICAD::CalculateTextLengthSize ( TTEXTVALUE aText)

Definition at line 506 of file pcad2kicad_common.cpp.

507 {
508  return KiROUND( (double) aText->text.Len() *
509  (double) aText->textHeight * TEXT_WIDTH_TO_SIZE_AVERAGE );
510 }
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:61

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

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

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_MODULE::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_TEXT::Parse(), PCAD2KICAD::PCB_PAD::Parse(), SetFontProperty(), and SetTextParameters().

◆ FindPinMap()

XNODE * PCAD2KICAD::FindPinMap ( XNODE aNode)

Definition at line 99 of file pcad2kicad_common.cpp.

100 {
101  XNODE* result, * lNode;
102 
103  result = NULL;
104  lNode = FindNode( aNode, wxT( "attachedPattern" ) );
105 
106  if( lNode )
107  result = FindNode( lNode, wxT( "padPinMap" ) );
108 
109  return result;
110 }
#define NULL
XNODE holds an XML or S-expression element.
Definition: xnode.h:43
XNODE * FindNode(XNODE *aChild, const wxString &aTag)

References FindNode(), and NULL.

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

◆ GetAndCutWordWithMeasureUnits()

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

Definition at line 178 of file pcad2kicad_common.cpp.

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

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

◆ GetJustifyIdentificator()

TTEXT_JUSTIFY PCAD2KICAD::GetJustifyIdentificator ( const wxString &  aJustify)

Definition at line 298 of file pcad2kicad_common.cpp.

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

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

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

◆ 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 = 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 }

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

◆ 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 = NULL, *cNode = NULL;
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  if( tok == DSN_STRING )
85  {
86  // update attribute
87  if( iNode->GetAttribute( wxT( "Name" ), &propValue ) )
88  {
89  iNode->DeleteAttribute( wxT( "Name" ) );
90  iNode->AddAttribute( wxT( "Name" ), propValue + wxT( ' ' ) + str );
91  }
92  else
93  iNode->AddAttribute( wxT( "Name" ), str );
94  }
95  else if( str != wxEmptyString )
96  {
97  // update node content
98  content = cNode->GetNodeContent() + wxT( ' ' ) + str;
99 
100  if( cNode->GetChildren() )
101  cNode->GetChildren()->SetContent( content );
102  else
103  cNode->AddChild( new wxXmlNode( wxXML_TEXT_NODE,
104  wxEmptyString,
105  content ) );
106  }
107  }
108  }
109 
110  if( iNode )
111  {
112  aXmlDoc->SetRoot( iNode );
113  //aXmlDoc->Save( wxT( "test.xml" ) );
114  }
115 }
XNODE * GetChildren() const
Definition: xnode.h:63
#define NULL
XNODE * GetParent() const
Definition: xnode.h:73
#define THROW_IO_ERROR(msg)
static const KEYWORD empty_keywords[1]
Definition: dsnlexer.cpp:125
XNODE holds an XML or S-expression element.
Definition: xnode.h:43
static const char ACCEL_ASCII_KEYWORD[]
DSNLEXER implements a lexical analyzer for the SPECCTRA DSN file format.
Definition: dsnlexer.h:79

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

Referenced by PCAD_PLUGIN::Load().

◆ SetDoublePrecisionPosition()

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

Definition at line 283 of file pcad2kicad_common.cpp.

288 {
290  aDefaultMeasurementUnit ), wxT( 'X' ),
291  aActualConversion );
293  aDefaultMeasurementUnit ), wxT( 'Y' ),
294  aActualConversion );
295 }
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.

383 {
384  wxString n, propValue;
385 
386  aNode->GetAttribute( wxT( "Name" ), &n );
387 
388  while( aNode->GetName() != wxT( "www.lura.sk" ) )
389  aNode = aNode->GetParent();
390 
391  aNode = FindNode( aNode, wxT( "library" ) );
392  if( aNode )
393  aNode = FindNode( aNode, wxT( "textStyleDef" ) );
394 
395  while( aNode )
396  {
397  aNode->GetAttribute( wxT( "Name" ), &propValue );
398  propValue.Trim( false );
399  propValue.Trim( true );
400 
401  if( propValue == n )
402  break;
403 
404  aNode = aNode->GetNext();
405  }
406 
407  if( aNode )
408  {
409  wxString fontType;
410 
411  propValue = FindNodeGetContent( aNode, wxT( "textStyleDisplayTType" ) );
412  aTextValue->isTrueType = ( propValue == wxT( "True" ) );
413 
414  aNode = FindNode( aNode, wxT( "font" ) );
415  fontType = FindNodeGetContent( aNode, wxT( "fontType" ) );
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  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  if( lNode )
441  SetHeight( lNode->GetNodeContent(), aDefaultMeasurementUnit,
442  &aTextValue->textHeight, aActualConversion );
443 
444  if( aTextValue->isTrueType )
445  {
446  aTextValue->textstrokeWidth = TRUETYPE_THICK_PER_HEIGHT * aTextValue->textHeight;
447  if( aTextValue->isBold )
448  aTextValue->textstrokeWidth *= TRUETYPE_BOLD_THICK_MUL;
449  }
450  else
451  {
452  lNode = FindNode( aNode, wxT( "strokeWidth" ) );
453  if( lNode )
454  SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit,
455  &aTextValue->textstrokeWidth, aActualConversion );
456  }
457  }
458  }
459 }
const long TRUETYPE_BOLD_MIN_WEIGHT
const double TRUETYPE_BOLD_THICK_MUL
const double TRUETYPE_THICK_PER_HEIGHT
void SetWidth(wxString aStr, const wxString &aDefaultMeasurementUnit, int *aWidth, const wxString &aActualConversion)
void SetHeight(wxString aStr, const wxString &aDefaultMeasurementUnit, int *aHeight, const wxString &aActualConversion)
XNODE * GetParent() const
Definition: xnode.h:73
wxString FindNodeGetContent(XNODE *aChild, const wxString &aTag)
XNODE holds an XML or S-expression element.
Definition: xnode.h:43
XNODE * GetNext() const
Definition: xnode.h:68
XNODE * FindNode(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_MODULE::DoLayerContentsObjects(), PCAD2KICAD::PCB_TEXT::Parse(), and SetTextParameters().

◆ SetHeight()

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

Definition at line 257 of file pcad2kicad_common.cpp.

261 {
262  *aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
263  aDefaultMeasurementUnit ), wxT( ' ' ),
264  aActualConversion );
265 }
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 ( wxString  aStr,
const wxString &  aDefaultMeasurementUnit,
int *  aX,
int *  aY,
const wxString &  aActualConversion 
)

Definition at line 268 of file pcad2kicad_common.cpp.

273 {
275  aDefaultMeasurementUnit ), wxT( 'X' ),
276  aActualConversion );
278  aDefaultMeasurementUnit ), wxT( 'Y' ),
279  aActualConversion );
280 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)
int StrToIntUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)

References GetAndCutWordWithMeasureUnits(), and StrToIntUnits().

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

◆ SetTextJustify()

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

Definition at line 462 of file pcad2kicad_common.cpp.

463 {
464  switch( aJustify )
465  {
466  case LowerLeft:
469  break;
470  case LowerCenter:
473  break;
474  case LowerRight:
477  break;
478  case UpperLeft:
481  break;
482  case UpperCenter:
485  break;
486  case UpperRight:
489  break;
490  case Left:
493  break;
494  case Center:
497  break;
498  case Right:
501  break;
502  }
503 }
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:187
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:186

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

329 {
330  XNODE* tNode;
331  wxString str;
332 
333  tNode = FindNode( aNode, wxT( "pt" ) );
334 
335  if( tNode )
336  SetPosition( tNode->GetNodeContent(),
337  aDefaultMeasurementUnit,
338  &aTextValue->textPositionX,
339  &aTextValue->textPositionY,
340  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)
void SetPosition(wxString aStr, const wxString &aDefaultMeasurementUnit, int *aX, int *aY, const wxString &aActualConversion)
wxString FindNodeGetContent(XNODE *aChild, const wxString &aTag)
XNODE holds 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)

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

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

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

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

◆ SetTextSizeFromTrueTypeFontHeight()

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

Definition at line 553 of file pcad2kicad_common.cpp.

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

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

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

◆ SetWidth()

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

Definition at line 246 of file pcad2kicad_common.cpp.

250 {
252  aDefaultMeasurementUnit ), wxT( ' ' ),
253  aActualConversion );
254 }
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_VIA::Parse(), PCAD2KICAD::PCB_ARC::Parse(), PCAD2KICAD::PCB_LINE::Parse(), PCAD2KICAD::PCB_PAD_SHAPE::Parse(), PCAD2KICAD::PCB_PAD::Parse(), and SetFontProperty().

◆ StrToDoublePrecisionUnits()

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

Definition at line 113 of file pcad2kicad_common.cpp.

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

Referenced by SetDoublePrecisionPosition(), and StrToIntUnits().

◆ StrToInt1Units()

int PCAD2KICAD::StrToInt1Units ( const wxString &  aStr)

Definition at line 217 of file pcad2kicad_common.cpp.

218 {
219  double num, precision = 10;
220 
221  aStr.ToDouble( &num );
222  return KiROUND( num * precision );
223 }
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:61

References KiROUND().

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

◆ StrToIntUnits()

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

Definition at line 172 of file pcad2kicad_common.cpp.

173 {
174  return KiROUND( StrToDoublePrecisionUnits( aStr, aAxe, aActualConversion ) );
175 }
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:61

References KiROUND(), and StrToDoublePrecisionUnits().

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

◆ ValidateName()

wxString PCAD2KICAD::ValidateName ( wxString  aName)

Definition at line 226 of file pcad2kicad_common.cpp.

227 {
228  aName.Replace( wxT( " " ), wxT( "_" ) );
229 
230  return aName;
231 }

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

◆ ValidateReference()

wxString PCAD2KICAD::ValidateReference ( wxString  aRef)

Definition at line 234 of file pcad2kicad_common.cpp.

235 {
236  wxRegEx reRef;
237  reRef.Compile( wxT( "^[[:digit:]][[:digit:]]*$" ) );
238 
239  if( reRef.Matches( aRef ) )
240  aRef.Prepend( wxT( '.' ) );
241 
242  return aRef;
243 }

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

◆ WX_DEFINE_ARRAY() [1/6]

PCAD2KICAD::WX_DEFINE_ARRAY ( VERTICES_ARRAY *  ,
ISLANDS_ARRAY   
)

◆ WX_DEFINE_ARRAY() [2/6]

PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_NET_NODE ,
PCB_NET_NODES_ARRAY   
)

◆ WX_DEFINE_ARRAY() [3/6]

PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_PAD_SHAPE ,
PCB_PAD_SHAPES_ARRAY   
)

◆ WX_DEFINE_ARRAY() [4/6]

PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_NET ,
PCB_NETS_ARRAY   
)

◆ WX_DEFINE_ARRAY() [5/6]

PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_COMPONENT ,
PCB_COMPONENTS_ARRAY   
)

◆ WX_DEFINE_ARRAY() [6/6]

PCAD2KICAD::WX_DEFINE_ARRAY ( wxRealPoint *  ,
VERTICES_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 43 of file pcad2kicad_common.cpp.

Referenced by CalculateTextLengthSize().

◆ TRUETYPE_BOLD_MIN_WEIGHT

const long PCAD2KICAD::TRUETYPE_BOLD_MIN_WEIGHT = 700

Definition at line 52 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_BOLD_THICK_MUL

const double PCAD2KICAD::TRUETYPE_BOLD_THICK_MUL = 1.6

Definition at line 51 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_HEIGHT_TO_SIZE

const double PCAD2KICAD::TRUETYPE_HEIGHT_TO_SIZE = 0.585

Definition at line 48 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromTrueTypeFontHeight().

◆ TRUETYPE_THICK_PER_HEIGHT

const double PCAD2KICAD::TRUETYPE_THICK_PER_HEIGHT = 0.073

Definition at line 50 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_WIDTH_TO_SIZE

const double PCAD2KICAD::TRUETYPE_WIDTH_TO_SIZE = 0.585

Definition at line 49 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromTrueTypeFontHeight().