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

506 {
507  return KiROUND( (double) aText->text.Len() *
508  (double) aText->textHeight * TEXT_WIDTH_TO_SIZE_AVERAGE );
509 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
const double TEXT_WIDTH_TO_SIZE_AVERAGE

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

513 {
514  int cm = aValue->mirror ? -1 : 1;
515  int cl = KiROUND( (double) CalculateTextLengthSize( aValue ) / 2.0 );
516  int ch = KiROUND( (double) aValue->textHeight / 2.0 );
517  int posX = 0;
518  int posY = 0;
519 
520  if( aValue->justify == LowerLeft ||
521  aValue->justify == Left ||
522  aValue->justify == UpperLeft )
523  posX += cl * cm;
524  else if( aValue->justify == LowerRight ||
525  aValue->justify == Right ||
526  aValue->justify == UpperRight )
527  posX -= cl * cm;
528 
529  if( aValue->justify == LowerLeft ||
530  aValue->justify == LowerCenter ||
531  aValue->justify == LowerRight )
532  posY -= ch;
533  else if( aValue->justify == UpperLeft ||
534  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 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:229
int CalculateTextLengthSize(TTEXTVALUE *aText)

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

◆ 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 }
const string & str
Definition: json11.cpp:596
XNODE * FindNode(XNODE *aChild, const wxString &aTag)

References FindNode(), and str.

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

99 {
100  XNODE* result, * lNode;
101 
102  result = NULL;
103  lNode = FindNode( aNode, wxT( "attachedPattern" ) );
104 
105  if( lNode )
106  result = FindNode( lNode, wxT( "padPinMap" ) );
107 
108  return result;
109 }
Class XNODE holds 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_MODULE::Parse().

◆ GetAndCutWordWithMeasureUnits()

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

Definition at line 177 of file pcad2kicad_common.cpp.

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

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

◆ GetJustifyIdentificator()

TTEXT_JUSTIFY PCAD2KICAD::GetJustifyIdentificator ( const wxString &  aJustify)

Definition at line 297 of file pcad2kicad_common.cpp.

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

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

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

◆ InitTTextValue()

void PCAD2KICAD::InitTTextValue ( TTEXTVALUE aTextValue)

Definition at line 590 of file pcad2kicad_common.cpp.

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

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 }
const string & str
Definition: json11.cpp:596
XNODE * GetParent() const
Definition: xnode.h:73
#define THROW_IO_ERROR(msg)
static const KEYWORD empty_keywords[1]
Definition: dsnlexer.cpp:125
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
static const char ACCEL_ASCII_KEYWORD[]
Class 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::GetParent(), DSNLEXER::NextTok(), str, 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 282 of file pcad2kicad_common.cpp.

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

382 {
383  wxString n, propValue;
384 
385  aNode->GetAttribute( wxT( "Name" ), &n );
386 
387  while( aNode->GetName() != wxT( "www.lura.sk" ) )
388  aNode = aNode->GetParent();
389 
390  aNode = FindNode( aNode, wxT( "library" ) );
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  if( ( aTextValue->isTrueType && ( fontType != wxT( "TrueType" ) ) ) ||
416  ( !aTextValue->isTrueType && ( fontType != wxT( "Stroke" ) ) ) )
417  aNode = aNode->GetNext();
418 
419  if( aNode )
420  {
421  if( aTextValue->isTrueType )
422  {
423  propValue = FindNodeGetContent( aNode, wxT( "fontItalic" ) );
424  aTextValue->isItalic = ( propValue == wxT( "True" ) );
425 
426  propValue = FindNodeGetContent( aNode, wxT( "fontWeight" ) );
427  if( propValue != wxEmptyString )
428  {
429  long fontWeight;
430 
431  propValue.ToLong( &fontWeight );
432  aTextValue->isBold = ( fontWeight >= TRUETYPE_BOLD_MIN_WEIGHT );
433  }
434  }
435 
436  XNODE* lNode;
437 
438  lNode = FindNode( aNode, wxT( "fontHeight" ) );
439  if( lNode )
440  SetHeight( lNode->GetNodeContent(), aDefaultMeasurementUnit,
441  &aTextValue->textHeight, aActualConversion );
442 
443  if( aTextValue->isTrueType )
444  {
445  aTextValue->textstrokeWidth = TRUETYPE_THICK_PER_HEIGHT * aTextValue->textHeight;
446  if( aTextValue->isBold )
447  aTextValue->textstrokeWidth *= TRUETYPE_BOLD_THICK_MUL;
448  }
449  else
450  {
451  lNode = FindNode( aNode, wxT( "strokeWidth" ) );
452  if( lNode )
453  SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit,
454  &aTextValue->textstrokeWidth, aActualConversion );
455  }
456  }
457  }
458 }
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)
Class 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 256 of file pcad2kicad_common.cpp.

260 {
261  *aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
262  aDefaultMeasurementUnit ), wxT( ' ' ),
263  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 SetFontProperty().

◆ SetPosition()

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

Definition at line 267 of file pcad2kicad_common.cpp.

272 {
274  aDefaultMeasurementUnit ), wxT( 'X' ),
275  aActualConversion );
277  aDefaultMeasurementUnit ), wxT( 'Y' ),
278  aActualConversion );
279 }
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 461 of file pcad2kicad_common.cpp.

462 {
463  switch( aJustify )
464  {
465  case LowerLeft:
468  break;
469  case LowerCenter:
472  break;
473  case LowerRight:
476  break;
477  case UpperLeft:
480  break;
481  case UpperCenter:
484  break;
485  case UpperRight:
488  break;
489  case Left:
492  break;
493  case Center:
496  break;
497  case Right:
500  break;
501  }
502 }
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:188
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:187

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

328 {
329  XNODE* tNode;
330  wxString str;
331 
332  tNode = FindNode( aNode, wxT( "pt" ) );
333 
334  if( tNode )
335  SetPosition( tNode->GetNodeContent(),
336  aDefaultMeasurementUnit,
337  &aTextValue->textPositionX,
338  &aTextValue->textPositionY,
339  aActualConversion );
340 
341  tNode = FindNode( aNode, wxT( "rotation" ) );
342 
343  if( tNode )
344  {
345  str = tNode->GetNodeContent();
346  str.Trim( false );
347  aTextValue->textRotation = StrToInt1Units( str );
348  }
349  else
350  {
351  aTextValue->textRotation = 0;
352  }
353 
354  str = FindNodeGetContent( aNode, wxT( "isVisible" ) );
355 
356  if( str == wxT( "True" ) )
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 == wxT( "True" ) )
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 }
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)
const string & str
Definition: json11.cpp:596
wxString FindNodeGetContent(XNODE *aChild, const wxString &aTag)
Class 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(), str, 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 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:220
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_TEXT::AddToBoard(), and PCAD2KICAD::PCB_MODULE::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 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:220
const double TRUETYPE_WIDTH_TO_SIZE
const double TRUETYPE_HEIGHT_TO_SIZE

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

249 {
251  aDefaultMeasurementUnit ), wxT( ' ' ),
252  aActualConversion );
253 }
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 112 of file pcad2kicad_common.cpp.

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

References i.

Referenced by SetDoublePrecisionPosition(), and StrToIntUnits().

◆ StrToInt1Units()

int PCAD2KICAD::StrToInt1Units ( const wxString &  aStr)

Definition at line 216 of file pcad2kicad_common.cpp.

217 {
218  double num, precision = 10;
219 
220  aStr.ToDouble( &num );
221  return KiROUND( num * precision );
222 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115

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

172 {
173  return KiROUND( StrToDoublePrecisionUnits( aStr, aAxe, aActualConversion ) );
174 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:115
double StrToDoublePrecisionUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)

References KiROUND(), and StrToDoublePrecisionUnits().

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

◆ ValidateName()

wxString PCAD2KICAD::ValidateName ( wxString  aName)

Definition at line 225 of file pcad2kicad_common.cpp.

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

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

◆ ValidateReference()

wxString PCAD2KICAD::ValidateReference ( wxString  aRef)

Definition at line 233 of file pcad2kicad_common.cpp.

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

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

Referenced by SetTextSizeFromStrokeFontHeight().

◆ STROKE_WIDTH_TO_SIZE

const double PCAD2KICAD::STROKE_WIDTH_TO_SIZE = 0.69

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

Referenced by SetFontProperty().

◆ TRUETYPE_BOLD_THICK_MUL

const double PCAD2KICAD::TRUETYPE_BOLD_THICK_MUL = 1.6

Definition at line 50 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_HEIGHT_TO_SIZE

const double PCAD2KICAD::TRUETYPE_HEIGHT_TO_SIZE = 0.585

Definition at line 47 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromTrueTypeFontHeight().

◆ TRUETYPE_THICK_PER_HEIGHT

const double PCAD2KICAD::TRUETYPE_THICK_PER_HEIGHT = 0.073

Definition at line 49 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

◆ TRUETYPE_WIDTH_TO_SIZE

const double PCAD2KICAD::TRUETYPE_WIDTH_TO_SIZE = 0.585

Definition at line 48 of file pcad2kicad_common.cpp.

Referenced by SetTextSizeFromTrueTypeFontHeight().