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

Enumeration Type Documentation

Enumerator
LowerLeft 
LowerCenter 
LowerRight 
UpperLeft 
UpperCenter 
UpperRight 
Left 
Center 
Right 

Definition at line 44 of file pcad2kicad_common.h.

Function Documentation

int PCAD2KICAD::CalculateTextLengthSize ( TTEXTVALUE aText)

Definition at line 507 of file pcad2kicad_common.cpp.

References KiROUND(), PCAD2KICAD::_TTEXTVALUE::text, and PCAD2KICAD::_TTEXTVALUE::textHeight.

Referenced by CorrectTextPosition().

508 {
509  return KiROUND( (double) aText->text.Len() *
510  (double) aText->textHeight * TEXT_WIDTH_TO_SIZE_AVERAGE );
511 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
const double TEXT_WIDTH_TO_SIZE_AVERAGE
void PCAD2KICAD::CorrectTextPosition ( TTEXTVALUE aValue)

Definition at line 514 of file pcad2kicad_common.cpp.

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

515 {
516  int cm = aValue->mirror ? -1 : 1;
517  int cl = KiROUND( (double) CalculateTextLengthSize( aValue ) / 2.0 );
518  int ch = KiROUND( (double) aValue->textHeight / 2.0 );
519  int posX = 0;
520  int posY = 0;
521 
522  if( aValue->justify == LowerLeft ||
523  aValue->justify == Left ||
524  aValue->justify == UpperLeft )
525  posX += cl * cm;
526  else if( aValue->justify == LowerRight ||
527  aValue->justify == Right ||
528  aValue->justify == UpperRight )
529  posX -= cl * cm;
530 
531  if( aValue->justify == LowerLeft ||
532  aValue->justify == LowerCenter ||
533  aValue->justify == LowerRight )
534  posY -= ch;
535  else if( aValue->justify == UpperLeft ||
536  aValue->justify == UpperCenter ||
537  aValue->justify == UpperRight )
538  posY += ch;
539 
540  RotatePoint( &posX, &posY, aValue->textRotation );
541 
542  aValue->correctedPositionX = aValue->textPositionX + posX;
543  aValue->correctedPositionY = aValue->textPositionY + posY;
544 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
void RotatePoint(int *pX, int *pY, double angle)
Definition: trigo.cpp:216
int CalculateTextLengthSize(TTEXTVALUE *aText)
XNODE * PCAD2KICAD::FindNode ( XNODE aChild,
const wxString &  aTag 
)
wxString PCAD2KICAD::FindNodeGetContent ( XNODE aChild,
const wxString &  aTag 
)

Definition at line 576 of file pcad2kicad_common.cpp.

References FindNode(), and str.

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

577 {
578  wxString str = wxEmptyString;
579 
580  aChild = FindNode( aChild, aTag );
581 
582  if( aChild )
583  {
584  str = aChild->GetNodeContent();
585  str.Trim( false );
586  str.Trim( true );
587  }
588 
589  return str;
590 }
const string & str
Definition: json11.cpp:596
XNODE * FindNode(XNODE *aChild, const wxString &aTag)
XNODE * PCAD2KICAD::FindPinMap ( XNODE aNode)

Definition at line 98 of file pcad2kicad_common.cpp.

References FindNode().

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

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)
wxString PCAD2KICAD::GetAndCutWordWithMeasureUnits ( wxString *  aStr,
const wxString &  aDefaultMeasurementUnit 
)

Definition at line 177 of file pcad2kicad_common.cpp.

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

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 }
TTEXT_JUSTIFY PCAD2KICAD::GetJustifyIdentificator ( const wxString &  aJustify)

Definition at line 299 of file pcad2kicad_common.cpp.

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

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

300 {
301  TTEXT_JUSTIFY id;
302 
303  if( aJustify == wxT( "LowerCenter" ) )
304  id = LowerCenter;
305  else if( aJustify == wxT( "LowerRight" ) )
306  id = LowerRight;
307  else if( aJustify == wxT( "UpperLeft" ) )
308  id = UpperLeft;
309  else if( aJustify == wxT( "UpperCenter" ) )
310  id = UpperCenter;
311  else if( aJustify == wxT( "UpperRight" ) )
312  id = UpperRight;
313  else if( aJustify == wxT( "Left" ) )
314  id = Left;
315  else if( aJustify == wxT( "Center" ) )
316  id = Center;
317  else if( aJustify == wxT( "Right" ) )
318  id = Right;
319  else
320  id = LowerLeft;
321 
322  return id;
323 }
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 }
void PCAD2KICAD::InitTTextValue ( TTEXTVALUE aTextValue)

Definition at line 592 of file pcad2kicad_common.cpp.

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

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 }
void PCAD2KICAD::LoadInputFile ( const wxString &  aFileName,
wxXmlDocument *  aXmlDoc 
)

Definition at line 40 of file s_expr_loader.cpp.

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

Referenced by PCAD_PLUGIN::Load().

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
void PCAD2KICAD::SetDoublePrecisionPosition ( wxString  aStr,
const wxString &  aDefaultMeasurementUnit,
double *  aX,
double *  aY,
const wxString &  aActualConversion 
)

Definition at line 284 of file pcad2kicad_common.cpp.

References GetAndCutWordWithMeasureUnits(), and StrToDoublePrecisionUnits().

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

289 {
291  aDefaultMeasurementUnit ), wxT( 'X' ),
292  aActualConversion );
294  aDefaultMeasurementUnit ), wxT( 'Y' ),
295  aActualConversion );
296 }
double StrToDoublePrecisionUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)
void PCAD2KICAD::SetFontProperty ( XNODE aNode,
TTEXTVALUE aTextValue,
const wxString &  aDefaultMeasurementUnit,
const wxString &  aActualConversion 
)

Definition at line 380 of file pcad2kicad_common.cpp.

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, and TRUETYPE_BOLD_THICK_MUL.

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

384 {
385  wxString n, propValue;
386 
387  aNode->GetAttribute( wxT( "Name" ), &n );
388 
389  while( aNode->GetName() != wxT( "www.lura.sk" ) )
390  aNode = aNode->GetParent();
391 
392  aNode = FindNode( aNode, wxT( "library" ) );
393  if( aNode )
394  aNode = FindNode( aNode, wxT( "textStyleDef" ) );
395 
396  while( aNode )
397  {
398  aNode->GetAttribute( wxT( "Name" ), &propValue );
399  propValue.Trim( false );
400  propValue.Trim( true );
401 
402  if( propValue == n )
403  break;
404 
405  aNode = aNode->GetNext();
406  }
407 
408  if( aNode )
409  {
410  wxString fontType;
411 
412  propValue = FindNodeGetContent( aNode, wxT( "textStyleDisplayTType" ) );
413  aTextValue->isTrueType = ( propValue == wxT( "True" ) );
414 
415  aNode = FindNode( aNode, wxT( "font" ) );
416  fontType = FindNodeGetContent( aNode, wxT( "fontType" ) );
417  if( ( aTextValue->isTrueType && ( fontType != wxT( "TrueType" ) ) ) ||
418  ( !aTextValue->isTrueType && ( fontType != wxT( "Stroke" ) ) ) )
419  aNode = aNode->GetNext();
420 
421  if( aNode )
422  {
423  if( aTextValue->isTrueType )
424  {
425  propValue = FindNodeGetContent( aNode, wxT( "fontItalic" ) );
426  aTextValue->isItalic = ( propValue == wxT( "True" ) );
427 
428  propValue = FindNodeGetContent( aNode, wxT( "fontWeight" ) );
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  if( lNode )
442  SetHeight( lNode->GetNodeContent(), aDefaultMeasurementUnit,
443  &aTextValue->textHeight, aActualConversion );
444 
445  if( aTextValue->isTrueType )
446  {
447  aTextValue->textstrokeWidth = TRUETYPE_THICK_PER_HEIGHT * aTextValue->textHeight;
448  if( aTextValue->isBold )
449  aTextValue->textstrokeWidth *= TRUETYPE_BOLD_THICK_MUL;
450  }
451  else
452  {
453  lNode = FindNode( aNode, wxT( "strokeWidth" ) );
454  if( lNode )
455  SetWidth( lNode->GetNodeContent(), aDefaultMeasurementUnit,
456  &aTextValue->textstrokeWidth, aActualConversion );
457  }
458  }
459  }
460 }
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 * FindNode(XNODE *aChild, const wxString &aTag)
XNODE * GetNext() const
Definition: xnode.h:68
void PCAD2KICAD::SetHeight ( wxString  aStr,
const wxString &  aDefaultMeasurementUnit,
int *  aHeight,
const wxString &  aActualConversion 
)

Definition at line 258 of file pcad2kicad_common.cpp.

References GetAndCutWordWithMeasureUnits(), and StrToIntUnits().

Referenced by SetFontProperty().

262 {
263  *aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
264  aDefaultMeasurementUnit ), wxT( ' ' ),
265  aActualConversion );
266 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)
int StrToIntUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)
void PCAD2KICAD::SetPosition ( wxString  aStr,
const wxString &  aDefaultMeasurementUnit,
int *  aX,
int *  aY,
const wxString &  aActualConversion 
)

Definition at line 269 of file pcad2kicad_common.cpp.

References GetAndCutWordWithMeasureUnits(), and StrToIntUnits().

Referenced by DIALOG_SCH_FIND::DIALOG_SCH_FIND(), PCAD2KICAD::PCB::DoPCBComponents(), PCAD2KICAD::PCB::GetBoardOutline(), SCH_ITEM::GetNetListItem(), MODULE::Models(), 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().

274 {
276  aDefaultMeasurementUnit ), wxT( 'X' ),
277  aActualConversion );
279  aDefaultMeasurementUnit ), wxT( 'Y' ),
280  aActualConversion );
281 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)
int StrToIntUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)
void PCAD2KICAD::SetTextJustify ( EDA_TEXT aText,
TTEXT_JUSTIFY  aJustify 
)

Definition at line 463 of file pcad2kicad_common.cpp.

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

464 {
465  switch( aJustify )
466  {
467  case LowerLeft:
470  break;
471  case LowerCenter:
474  break;
475  case LowerRight:
478  break;
479  case UpperLeft:
482  break;
483  case UpperCenter:
486  break;
487  case UpperRight:
490  break;
491  case Left:
494  break;
495  case Center:
498  break;
499  case Right:
502  break;
503  }
504 }
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:207
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:206
void PCAD2KICAD::SetTextParameters ( XNODE aNode,
TTEXTVALUE aTextValue,
const wxString &  aDefaultMeasurementUnit,
const wxString &  aActualConversion 
)

Definition at line 326 of file pcad2kicad_common.cpp.

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

330 {
331  XNODE* tNode;
332  wxString str;
333 
334  tNode = FindNode( aNode, wxT( "pt" ) );
335 
336  if( tNode )
337  SetPosition( tNode->GetNodeContent(),
338  aDefaultMeasurementUnit,
339  &aTextValue->textPositionX,
340  &aTextValue->textPositionY,
341  aActualConversion );
342 
343  tNode = FindNode( aNode, wxT( "rotation" ) );
344 
345  if( tNode )
346  {
347  str = tNode->GetNodeContent();
348  str.Trim( false );
349  aTextValue->textRotation = StrToInt1Units( str );
350  }
351  else
352  {
353  aTextValue->textRotation = 0;
354  }
355 
356  str = FindNodeGetContent( aNode, wxT( "isVisible" ) );
357 
358  if( str == wxT( "True" ) )
359  aTextValue->textIsVisible = 1;
360  else
361  aTextValue->textIsVisible = 0;
362 
363  str = FindNodeGetContent( aNode, wxT( "justify" ) );
364  aTextValue->justify = GetJustifyIdentificator( str );
365 
366  str = FindNodeGetContent( aNode, wxT( "isFlipped" ) );
367 
368  if( str == wxT( "True" ) )
369  aTextValue->mirror = 1;
370  else
371  aTextValue->mirror = 0;
372 
373  tNode = FindNode( aNode, wxT( "textStyleRef" ) );
374 
375  if( tNode )
376  SetFontProperty( tNode, aTextValue, aDefaultMeasurementUnit, aActualConversion );
377 }
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)
void PCAD2KICAD::SetTextSizeFromStrokeFontHeight ( EDA_TEXT aText,
int  aTextHeight 
)

Definition at line 547 of file pcad2kicad_common.cpp.

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

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

548 {
549  aText->SetTextSize( wxSize( KiROUND( aTextHeight * STROKE_WIDTH_TO_SIZE ),
550  KiROUND( aTextHeight * STROKE_HEIGHT_TO_SIZE ) ) );
551 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
const double STROKE_WIDTH_TO_SIZE
const double STROKE_HEIGHT_TO_SIZE
void PCAD2KICAD::SetTextSizeFromTrueTypeFontHeight ( EDA_TEXT aText,
int  aTextHeight 
)

Definition at line 554 of file pcad2kicad_common.cpp.

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

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

555 {
556  aText->SetTextSize( wxSize( KiROUND( aTextHeight * TRUETYPE_WIDTH_TO_SIZE ),
557  KiROUND( aTextHeight * TRUETYPE_HEIGHT_TO_SIZE ) ) );
558 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:227
const double TRUETYPE_WIDTH_TO_SIZE
const double TRUETYPE_HEIGHT_TO_SIZE
void PCAD2KICAD::SetWidth ( wxString  aStr,
const wxString &  aDefaultMeasurementUnit,
int *  aWidth,
const wxString &  aActualConversion 
)

Definition at line 247 of file pcad2kicad_common.cpp.

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

251 {
253  aDefaultMeasurementUnit ), wxT( ' ' ),
254  aActualConversion );
255 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, const wxString &aDefaultMeasurementUnit)
int StrToIntUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)
double PCAD2KICAD::StrToDoublePrecisionUnits ( const wxString &  aStr,
char  aAxe,
const wxString &  aActualConversion 
)

Definition at line 112 of file pcad2kicad_common.cpp.

References i.

Referenced by SetDoublePrecisionPosition(), and StrToIntUnits().

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
int PCAD2KICAD::StrToInt1Units ( const wxString &  aStr)

Definition at line 216 of file pcad2kicad_common.cpp.

References KiROUND().

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

217 {
218  double num, precision = 10;
219 
220  // TODO: Is the following commented string necessary?
221  // if (pos(',',s)>0) then DecimalSeparator:=',' else DecimalSeparator:='.';
222  aStr.ToDouble( &num );
223  return KiROUND( num * precision );
224 }
static int KiROUND(double v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: common.h:120
int PCAD2KICAD::StrToIntUnits ( const wxString &  aStr,
char  aAxe,
const wxString &  aActualConversion 
)

Definition at line 171 of file pcad2kicad_common.cpp.

References KiROUND(), and StrToDoublePrecisionUnits().

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

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:120
double StrToDoublePrecisionUnits(const wxString &aStr, char aAxe, const wxString &aActualConversion)
wxString PCAD2KICAD::ValidateName ( wxString  aName)

Definition at line 227 of file pcad2kicad_common.cpp.

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

228 {
229  aName.Replace( wxT( " " ), wxT( "_" ) );
230 
231  return aName;
232 }
wxString PCAD2KICAD::ValidateReference ( wxString  aRef)

Definition at line 235 of file pcad2kicad_common.cpp.

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

236 {
237  wxRegEx reRef;
238  reRef.Compile( wxT( "^[[:digit:]][[:digit:]]*$" ) );
239 
240  if( reRef.Matches( aRef ) )
241  aRef.Prepend( wxT( '.' ) );
242 
243  return aRef;
244 }
PCAD2KICAD::WX_DEFINE_ARRAY ( VERTICES_ARRAY *  ,
ISLANDS_ARRAY   
)
PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_NET_NODE ,
PCB_NET_NODES_ARRAY   
)
PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_PAD_SHAPE ,
PCB_PAD_SHAPES_ARRAY   
)
PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_NET ,
PCB_NETS_ARRAY   
)
PCAD2KICAD::WX_DEFINE_ARRAY ( PCB_COMPONENT ,
PCB_COMPONENTS_ARRAY   
)
PCAD2KICAD::WX_DEFINE_ARRAY ( wxRealPoint *  ,
VERTICES_ARRAY   
)

Variable Documentation

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

Definition at line 38 of file s_expr_loader.cpp.

Referenced by LoadInputFile().

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

Definition at line 37 of file s_expr_loader.cpp.

const double PCAD2KICAD::STROKE_HEIGHT_TO_SIZE = 0.656

Definition at line 44 of file pcad2kicad_common.cpp.

const double PCAD2KICAD::STROKE_WIDTH_TO_SIZE = 0.69

Definition at line 45 of file pcad2kicad_common.cpp.

const double PCAD2KICAD::TEXT_WIDTH_TO_SIZE_AVERAGE = 0.5

Definition at line 42 of file pcad2kicad_common.cpp.

const long PCAD2KICAD::TRUETYPE_BOLD_MIN_WEIGHT = 700

Definition at line 51 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

const double PCAD2KICAD::TRUETYPE_BOLD_THICK_MUL = 1.6

Definition at line 50 of file pcad2kicad_common.cpp.

Referenced by SetFontProperty().

const double PCAD2KICAD::TRUETYPE_HEIGHT_TO_SIZE = 0.585

Definition at line 47 of file pcad2kicad_common.cpp.

const double PCAD2KICAD::TRUETYPE_THICK_PER_HEIGHT = 0.073

Definition at line 49 of file pcad2kicad_common.cpp.

const double PCAD2KICAD::TRUETYPE_WIDTH_TO_SIZE = 0.585

Definition at line 48 of file pcad2kicad_common.cpp.