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 (wxString aStr, char aAxe, wxString aActualConversion)
 
int StrToIntUnits (wxString aStr, char aAxe, wxString aActualConversion)
 
wxString GetAndCutWordWithMeasureUnits (wxString *aStr, wxString aDefaultMeasurementUnit)
 
int StrToInt1Units (wxString aStr)
 
wxString ValidateName (wxString aName)
 
void SetWidth (wxString aStr, wxString aDefaultMeasurementUnit, int *aWidth, wxString aActualConversion)
 
void SetHeight (wxString aStr, wxString aDefaultMeasurementUnit, int *aHeight, wxString aActualConversion)
 
void SetPosition (wxString aStr, wxString aDefaultMeasurementUnit, int *aX, int *aY, wxString aActualConversion)
 
void SetDoublePrecisionPosition (wxString aStr, wxString aDefaultMeasurementUnit, double *aX, double *aY, wxString aActualConversion)
 
TTEXT_JUSTIFY GetJustifyIdentificator (wxString aJustify)
 
void SetTextParameters (XNODE *aNode, TTEXTVALUE *aTextValue, wxString aDefaultMeasurementUnit, wxString aActualConversion)
 
void SetFontProperty (XNODE *aNode, TTEXTVALUE *aTextValue, wxString aDefaultMeasurementUnit, 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)
 
XNODEFindNode (XNODE *aChild, wxString aTag)
 
wxString FindNodeGetContent (XNODE *aChild, 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 (wxString aFileName, wxXmlDocument *aXmlDoc)
 

Variables

const double TEXT_WIDTH_TO_SIZE_AVERAGE = 0.79
 
const double TEXT_HEIGHT_TO_SIZE = 0.656
 
const double TEXT_WIDTH_TO_SIZE = 0.656
 
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 452 of file pcad2kicad_common.cpp.

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

Referenced by CorrectTextPosition().

453 {
454  return KiROUND( (double) aText->text.Len() *
455  (double) aText->textHeight * TEXT_WIDTH_TO_SIZE_AVERAGE );
456 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
const double TEXT_WIDTH_TO_SIZE_AVERAGE
void PCAD2KICAD::CorrectTextPosition ( TTEXTVALUE aValue)

Definition at line 458 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, PCAD2KICAD::_TTEXTVALUE::textHeight, PCAD2KICAD::_TTEXTVALUE::textPositionX, PCAD2KICAD::_TTEXTVALUE::textPositionY, PCAD2KICAD::_TTEXTVALUE::textRotation, UpperCenter, UpperLeft, and UpperRight.

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

459 {
460  int cm = aValue->mirror ? -1 : 1;
461  // sizes of justify correction
462  int cl = KiROUND( (double) CalculateTextLengthSize( aValue ) / 2.0 );
463  int ch = KiROUND( (double) aValue->textHeight / 2.0 );
464 
465  aValue->correctedPositionX = aValue->textPositionX;
466  aValue->correctedPositionY = aValue->textPositionY;
467 
468  switch( aValue->textRotation )
469  {
470  case 0:
471  if( aValue->justify == LowerLeft ||
472  aValue->justify == Left ||
473  aValue->justify == UpperLeft )
474  aValue->correctedPositionX += cl * cm;
475  else if( aValue->justify == LowerRight ||
476  aValue->justify == Right ||
477  aValue->justify == UpperRight )
478  aValue->correctedPositionX -= cl * cm;
479 
480  if( aValue->justify == LowerLeft ||
481  aValue->justify == LowerCenter ||
482  aValue->justify == LowerRight )
483  aValue->correctedPositionY -= ch;
484  else if( aValue->justify == UpperLeft ||
485  aValue->justify == UpperCenter ||
486  aValue->justify == UpperRight )
487  aValue->correctedPositionY += ch;
488  break;
489  case 900:
490  if( aValue->justify == LowerLeft ||
491  aValue->justify == LowerCenter ||
492  aValue->justify == LowerRight )
493  aValue->correctedPositionX -= ch * cm;
494  else if( aValue->justify == UpperLeft ||
495  aValue->justify == UpperCenter ||
496  aValue->justify == UpperRight )
497  aValue->correctedPositionX += ch * cm;
498 
499  if( aValue->justify == LowerLeft ||
500  aValue->justify == Left ||
501  aValue->justify == UpperLeft )
502  aValue->correctedPositionY -= cl;
503  else if( aValue->justify == LowerRight ||
504  aValue->justify == Right ||
505  aValue->justify == UpperRight )
506  aValue->correctedPositionY += cl;
507  break;
508  case 1800:
509  if( aValue->justify == LowerLeft ||
510  aValue->justify == Left ||
511  aValue->justify == UpperLeft )
512  aValue->correctedPositionX -= cl * cm;
513  else if( aValue->justify == LowerRight ||
514  aValue->justify == Right ||
515  aValue->justify == UpperRight )
516  aValue->correctedPositionX += cl * cm;
517 
518  if( aValue->justify == LowerLeft ||
519  aValue->justify == LowerCenter ||
520  aValue->justify == LowerRight )
521  aValue->correctedPositionY += ch;
522  else if( aValue->justify == UpperLeft ||
523  aValue->justify == UpperCenter ||
524  aValue->justify == UpperRight )
525  aValue->correctedPositionY -= ch;
526  break;
527  case 2700:
528  if( aValue->justify == LowerLeft ||
529  aValue->justify == LowerCenter ||
530  aValue->justify == LowerRight )
531  aValue->correctedPositionX += ch * cm;
532  else if( aValue->justify == UpperLeft ||
533  aValue->justify == UpperCenter ||
534  aValue->justify == UpperRight )
535  aValue->correctedPositionX -= ch * cm;
536 
537  if( aValue->justify == LowerLeft ||
538  aValue->justify == Left ||
539  aValue->justify == UpperLeft )
540  aValue->correctedPositionY += cl;
541  else if( aValue->justify == LowerRight ||
542  aValue->justify == Right ||
543  aValue->justify == UpperRight )
544  aValue->correctedPositionY -= cl;
545  break;
546  default:
547  break;
548  }
549 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
int CalculateTextLengthSize(TTEXTVALUE *aText)
wxString PCAD2KICAD::FindNodeGetContent ( XNODE aChild,
wxString  aTag 
)

Definition at line 574 of file pcad2kicad_common.cpp.

References FindNode().

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

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

Definition at line 91 of file pcad2kicad_common.cpp.

References FindNode().

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

92 {
93  XNODE* result, * lNode;
94 
95  result = NULL;
96  lNode = FindNode( aNode, wxT( "attachedPattern" ) );
97 
98  if( lNode )
99  result = FindNode( lNode, wxT( "padPinMap" ) );
100 
101  return result;
102 }
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
XNODE * FindNode(XNODE *aChild, wxString aTag)
wxString PCAD2KICAD::GetAndCutWordWithMeasureUnits ( wxString *  aStr,
wxString  aDefaultMeasurementUnit 
)

Definition at line 170 of file pcad2kicad_common.cpp.

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

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

Definition at line 279 of file pcad2kicad_common.cpp.

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

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

280 {
281  TTEXT_JUSTIFY id;
282 
283  if( aJustify == wxT( "LowerCenter" ) )
284  id = LowerCenter;
285  else if( aJustify == wxT( "LowerRight" ) )
286  id = LowerRight;
287  else if( aJustify == wxT( "UpperLeft" ) )
288  id = UpperLeft;
289  else if( aJustify == wxT( "UpperCenter" ) )
290  id = UpperCenter;
291  else if( aJustify == wxT( "UpperRight" ) )
292  id = UpperRight;
293  else if( aJustify == wxT( "Left" ) )
294  id = Left;
295  else if( aJustify == wxT( "Center" ) )
296  id = Center;
297  else if( aJustify == wxT( "Right" ) )
298  id = Right;
299  else
300  id = LowerLeft;
301 
302  return id;
303 }
wxString PCAD2KICAD::GetWord ( wxString *  aStr)

Definition at line 46 of file pcad2kicad_common.cpp.

47 {
48  wxString result = wxEmptyString;
49 
50  *aStr = aStr->Trim( false );
51 
52  if( aStr->Len() == 0 )
53  return result;
54 
55  if( (*aStr)[0] == wxT( '"' ) )
56  {
57  result += (*aStr)[0];
58  *aStr = aStr->Mid( 1 ); // remove Frot apostrofe
59 
60  while( aStr->Len() > 0 && (*aStr)[0] != wxT( '"' ) )
61  {
62  result += (*aStr)[0];
63  *aStr = aStr->Mid( 1 );
64  }
65 
66  if( aStr->Len() > 0 && (*aStr)[0] == wxT( '"' ) )
67  {
68  result += (*aStr)[0];
69  *aStr = aStr->Mid( 1 ); // remove ending apostrophe
70  }
71  }
72  else
73  {
74  while( aStr->Len() > 0
75  && !( (*aStr)[0] == wxT( ' ' )
76  || (*aStr)[0] == wxT( '(' )
77  || (*aStr)[0] == wxT( ')' ) ) )
78  {
79  result += (*aStr)[0];
80  *aStr = aStr->Mid( 1 );
81  }
82  }
83 
84  result.Trim( true );
85  result.Trim( false );
86 
87  return result;
88 }
void PCAD2KICAD::InitTTextValue ( TTEXTVALUE aTextValue)

Definition at line 590 of file pcad2kicad_common.cpp.

References PCAD2KICAD::_TTEXTVALUE::correctedPositionX, PCAD2KICAD::_TTEXTVALUE::correctedPositionY, 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().

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

Definition at line 39 of file s_expr_loader.cpp.

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

Referenced by PCAD_PLUGIN::Load().

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

Definition at line 265 of file pcad2kicad_common.cpp.

References GetAndCutWordWithMeasureUnits(), and StrToDoublePrecisionUnits().

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

270 {
272  aDefaultMeasurementUnit ), wxT( 'X' ),
273  aActualConversion );
275  aDefaultMeasurementUnit ), wxT( 'Y' ),
276  aActualConversion );
277 }
double StrToDoublePrecisionUnits(wxString aStr, char aAxe, wxString aActualConversion)
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, wxString aDefaultMeasurementUnit)
void PCAD2KICAD::SetFontProperty ( XNODE aNode,
TTEXTVALUE aTextValue,
wxString  aDefaultMeasurementUnit,
wxString  aActualConversion 
)

Definition at line 353 of file pcad2kicad_common.cpp.

References FindNode(), XNODE::GetNext(), XNODE::GetParent(), SetHeight(), SetWidth(), PCAD2KICAD::_TTEXTVALUE::textHeight, and PCAD2KICAD::_TTEXTVALUE::textstrokeWidth.

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

357 {
358  wxString n, propValue;
359 
360  aNode->GetAttribute( wxT( "Name" ), &n );
361 
362  while( aNode->GetName() != wxT( "www.lura.sk" ) )
363  aNode = aNode->GetParent();
364 
365  aNode = FindNode( aNode, wxT( "library" ) );
366 
367  if( aNode )
368  aNode = FindNode( aNode, wxT( "textStyleDef" ) );
369 
370  if( aNode )
371  {
372  while( true )
373  {
374  aNode->GetAttribute( wxT( "Name" ), &propValue );
375  propValue.Trim( false );
376  propValue.Trim( true );
377 
378  if( propValue == n )
379  break;
380 
381  aNode = aNode->GetNext();
382  }
383 
384  if( aNode )
385  {
386  aNode = FindNode( aNode, wxT( "font" ) );
387 
388  if( aNode )
389  {
390  if( FindNode( aNode, wxT( "fontHeight" ) ) )
391  // // SetWidth(iNode.ChildNodes.FindNode('fontHeight').Text,
392  // // DefaultMeasurementUnit,tv.TextHeight);
393  // Fixed By Lubo, 02/2008
394  SetHeight( FindNode( aNode, wxT(
395  "fontHeight" ) )->GetNodeContent(),
396  aDefaultMeasurementUnit, &aTextValue->textHeight,
397  aActualConversion );
398 
399  if( FindNode( aNode, wxT( "strokeWidth" ) ) )
400  SetWidth( FindNode( aNode, wxT(
401  "strokeWidth" ) )->GetNodeContent(),
402  aDefaultMeasurementUnit, &aTextValue->textstrokeWidth,
403  aActualConversion );
404  }
405  }
406  }
407 }
void SetWidth(wxString aStr, wxString aDefaultMeasurementUnit, int *aWidth, wxString aActualConversion)
XNODE * GetParent() const
Definition: xnode.h:73
void SetHeight(wxString aStr, wxString aDefaultMeasurementUnit, int *aHeight, wxString aActualConversion)
XNODE * FindNode(XNODE *aChild, wxString aTag)
XNODE * GetNext() const
Definition: xnode.h:68
void PCAD2KICAD::SetHeight ( wxString  aStr,
wxString  aDefaultMeasurementUnit,
int *  aHeight,
wxString  aActualConversion 
)

Definition at line 239 of file pcad2kicad_common.cpp.

References GetAndCutWordWithMeasureUnits(), and StrToIntUnits().

Referenced by SetFontProperty().

243 {
244  *aHeight = StrToIntUnits( GetAndCutWordWithMeasureUnits( &aStr,
245  aDefaultMeasurementUnit ), wxT( ' ' ),
246  aActualConversion );
247 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, wxString aDefaultMeasurementUnit)
int StrToIntUnits(wxString aStr, char aAxe, wxString aActualConversion)
void PCAD2KICAD::SetPosition ( wxString  aStr,
wxString  aDefaultMeasurementUnit,
int *  aX,
int *  aY,
wxString  aActualConversion 
)

Definition at line 250 of file pcad2kicad_common.cpp.

References GetAndCutWordWithMeasureUnits(), and StrToIntUnits().

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

255 {
257  aDefaultMeasurementUnit ), wxT( 'X' ),
258  aActualConversion );
260  aDefaultMeasurementUnit ), wxT( 'Y' ),
261  aActualConversion );
262 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, wxString aDefaultMeasurementUnit)
int StrToIntUnits(wxString aStr, char aAxe, wxString aActualConversion)
void PCAD2KICAD::SetTextJustify ( EDA_TEXT aText,
TTEXT_JUSTIFY  aJustify 
)

Definition at line 409 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().

410 {
411  switch( aJustify )
412  {
413  case LowerLeft:
416  break;
417  case LowerCenter:
420  break;
421  case LowerRight:
424  break;
425  case UpperLeft:
428  break;
429  case UpperCenter:
432  break;
433  case UpperRight:
436  break;
437  case Left:
440  break;
441  case Center:
444  break;
445  case Right:
448  break;
449  }
450 }
void SetVertJustify(EDA_TEXT_VJUSTIFY_T aType)
Definition: eda_text.h:194
void SetHorizJustify(EDA_TEXT_HJUSTIFY_T aType)
Definition: eda_text.h:193
void PCAD2KICAD::SetTextParameters ( XNODE aNode,
TTEXTVALUE aTextValue,
wxString  aDefaultMeasurementUnit,
wxString  aActualConversion 
)

Definition at line 305 of file pcad2kicad_common.cpp.

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

309 {
310  XNODE* tNode;
311  wxString str;
312 
313  tNode = FindNode( aNode, wxT( "pt" ) );
314 
315  if( tNode )
316  SetPosition( tNode->GetNodeContent(),
317  aDefaultMeasurementUnit,
318  &aTextValue->textPositionX,
319  &aTextValue->textPositionY,
320  aActualConversion );
321 
322  tNode = FindNode( aNode, wxT( "rotation" ) );
323 
324  if( tNode )
325  {
326  str = tNode->GetNodeContent();
327  str.Trim( false );
328  aTextValue->textRotation = StrToInt1Units( str );
329  }
330 
331  str = FindNodeGetContent( aNode, wxT( "isVisible" ) );
332 
333  if( str == wxT( "True" ) )
334  aTextValue->textIsVisible = 1;
335  else if( str == wxT( "False" ) )
336  aTextValue->textIsVisible = 0;
337 
338  str = FindNodeGetContent( aNode, wxT( "justify" ) );
339  aTextValue->justify = GetJustifyIdentificator( str );
340 
341  str = FindNodeGetContent( aNode, wxT( "isFlipped" ) );
342 
343  if( str == wxT( "True" ) )
344  aTextValue->mirror = 1;
345 
346  tNode = FindNode( aNode, wxT( "textStyleRef" ) );
347 
348  if( tNode )
349  SetFontProperty( tNode, aTextValue, aDefaultMeasurementUnit, aActualConversion );
350 }
int StrToInt1Units(wxString aStr)
TTEXT_JUSTIFY GetJustifyIdentificator(wxString aJustify)
wxString FindNodeGetContent(XNODE *aChild, wxString aTag)
void SetPosition(wxString aStr, wxString aDefaultMeasurementUnit, int *aX, int *aY, wxString aActualConversion)
void SetFontProperty(XNODE *aNode, TTEXTVALUE *aTextValue, wxString aDefaultMeasurementUnit, wxString aActualConversion)
Class XNODE holds an XML or S-expression element.
Definition: xnode.h:43
XNODE * FindNode(XNODE *aChild, wxString aTag)
void PCAD2KICAD::SetTextSizeFromStrokeFontHeight ( EDA_TEXT aText,
int  aTextHeight 
)

Definition at line 552 of file pcad2kicad_common.cpp.

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

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

553 {
554  aText->SetTextSize( wxSize( KiROUND( aTextHeight * TEXT_WIDTH_TO_SIZE ),
555  KiROUND( aTextHeight * TEXT_HEIGHT_TO_SIZE ) ) );
556 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
void SetTextSize(const wxSize &aNewSize)
Definition: eda_text.h:214
const double TEXT_HEIGHT_TO_SIZE
const double TEXT_WIDTH_TO_SIZE
void PCAD2KICAD::SetWidth ( wxString  aStr,
wxString  aDefaultMeasurementUnit,
int *  aWidth,
wxString  aActualConversion 
)

Definition at line 228 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().

232 {
234  aDefaultMeasurementUnit ), wxT( ' ' ),
235  aActualConversion );
236 }
wxString GetAndCutWordWithMeasureUnits(wxString *aStr, wxString aDefaultMeasurementUnit)
int StrToIntUnits(wxString aStr, char aAxe, wxString aActualConversion)
double PCAD2KICAD::StrToDoublePrecisionUnits ( wxString  aStr,
char  aAxe,
wxString  aActualConversion 
)

Definition at line 105 of file pcad2kicad_common.cpp.

Referenced by SetDoublePrecisionPosition(), and StrToIntUnits().

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

Definition at line 209 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().

210 {
211  double num, precision = 10;
212 
213  // TODO: Is the following commented string necessary?
214  // if (pos(',',s)>0) then DecimalSeparator:=',' else DecimalSeparator:='.';
215  aStr.ToDouble( &num );
216  return KiROUND( num * precision );
217 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
int PCAD2KICAD::StrToIntUnits ( wxString  aStr,
char  aAxe,
wxString  aActualConversion 
)

Definition at line 164 of file pcad2kicad_common.cpp.

References KiROUND(), and StrToDoublePrecisionUnits().

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

165 {
166  return KiROUND( StrToDoublePrecisionUnits( aStr, aAxe, aActualConversion ) );
167 }
static int KiROUND(double v)
KiROUND rounds a floating point number to an int using "round halfway cases away from zero"...
Definition: common.h:107
double StrToDoublePrecisionUnits(wxString aStr, char aAxe, wxString aActualConversion)
wxString PCAD2KICAD::ValidateName ( wxString  aName)

Definition at line 220 of file pcad2kicad_common.cpp.

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

221 {
222  aName.Replace( wxT( " " ), wxT( "_" ) );
223 
224  return aName;
225 }
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 37 of file s_expr_loader.cpp.

Referenced by LoadInputFile().

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

Definition at line 36 of file s_expr_loader.cpp.

const double PCAD2KICAD::TEXT_HEIGHT_TO_SIZE = 0.656

Definition at line 43 of file pcad2kicad_common.cpp.

const double PCAD2KICAD::TEXT_WIDTH_TO_SIZE = 0.656

Definition at line 44 of file pcad2kicad_common.cpp.

const double PCAD2KICAD::TEXT_WIDTH_TO_SIZE_AVERAGE = 0.79

Definition at line 41 of file pcad2kicad_common.cpp.