KiCad PCB EDA Suite
altium_parser_sch.cpp File Reference
#include <iostream>
#include <unordered_map>
#include <convert_to_biu.h>
#include <ki_exception.h>
#include "plugins/altium/altium_parser.h"
#include "sch_plugins/altium/altium_parser_sch.h"

Go to the source code of this file.

Functions

ALTIUM_SCH_RECORD PropertiesReadRecord (const std::map< wxString, wxString > &aProperties)
 
constexpr int Altium2KiCadUnit (const int val, const int frac)
 
int PropertiesReadKiCadUnitFrac (const std::map< wxString, wxString > &aProperties, const wxString &aKey)
 
int PropertiesReadKiCadUnitFrac1 (const std::map< wxString, wxString > &aProperties, const wxString &aKey)
 
template<typename T >
PropertiesReadEnum (const std::map< wxString, wxString > &aProperties, const wxString &aKey, int aLower, int aUpper, T aDefault)
 
wxPoint ASchSheetGetSize (ASCH_SHEET_SIZE aSheetSize)
 

Function Documentation

◆ Altium2KiCadUnit()

constexpr int Altium2KiCadUnit ( const int  val,
const int  frac 
)

Definition at line 41 of file altium_parser_sch.cpp.

42 {
43  return Mils2iu( val ) * 10 + Mils2iu( frac ) / 10000; // TODO: correct, rounding issues?
44 }

Referenced by ASCH_PIN::ASCH_PIN(), PropertiesReadKiCadUnitFrac(), and PropertiesReadKiCadUnitFrac1().

◆ ASchSheetGetSize()

wxPoint ASchSheetGetSize ( ASCH_SHEET_SIZE  aSheetSize)

Definition at line 594 of file altium_parser_sch.cpp.

595 {
596  // From: https://github.com/vadmium/python-altium/blob/master/format.md#sheet
597  switch( aSheetSize )
598  {
599  default:
600  case ASCH_SHEET_SIZE::A4:
601  return { 1150, 760 };
602  case ASCH_SHEET_SIZE::A3:
603  return { 1550, 1110 };
604  case ASCH_SHEET_SIZE::A2:
605  return { 2230, 1570 };
606  case ASCH_SHEET_SIZE::A1:
607  return { 3150, 2230 };
608  case ASCH_SHEET_SIZE::A0:
609  return { 4460, 3150 };
610  case ASCH_SHEET_SIZE::A:
611  return { 950, 750 };
612  case ASCH_SHEET_SIZE::B:
613  return { 1500, 950 };
614  case ASCH_SHEET_SIZE::C:
615  return { 2000, 1500 };
616  case ASCH_SHEET_SIZE::D:
617  return { 3200, 2000 };
618  case ASCH_SHEET_SIZE::E:
619  return { 4200, 3200 };
621  return { 1100, 850 };
623  return { 1400, 850 };
625  return { 1700, 1100 };
627  return { 990, 790 };
629  return { 1540, 990 };
631  return { 2060, 1560 };
633  return { 3260, 2060 };
635  return { 4280, 3280 };
636  }
637 }

References A, A0, A1, A2, A3, A4, B, C, D, E, LEGAL, LETTER, ORCAD_A, ORCAD_B, ORCAD_C, ORCAD_D, ORCAD_E, and TABLOID.

◆ PropertiesReadEnum()

template<typename T >
T PropertiesReadEnum ( const std::map< wxString, wxString > &  aProperties,
const wxString &  aKey,
int  aLower,
int  aUpper,
aDefault 
)

Definition at line 69 of file altium_parser_sch.cpp.

71 {
72  int value = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey, static_cast<int>( aDefault ) );
73  if( value < aLower || value > aUpper )
74  return aDefault;
75  else
76  return static_cast<T>( value );
77 }
static int PropertiesReadInt(const std::map< wxString, wxString > &aProperties, const wxString &aKey, int aDefault)

References ALTIUM_PARSER::PropertiesReadInt().

◆ PropertiesReadKiCadUnitFrac()

int PropertiesReadKiCadUnitFrac ( const std::map< wxString, wxString > &  aProperties,
const wxString &  aKey 
)

Definition at line 47 of file altium_parser_sch.cpp.

49 {
50  // a unit is stored using two fields, denoting the size in mils and a fraction size
51  int key = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey, 0 );
52  int keyFrac = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey + "_FRAC", 0 );
53  return Altium2KiCadUnit( key, keyFrac );
54 }
static int PropertiesReadInt(const std::map< wxString, wxString > &aProperties, const wxString &aKey, int aDefault)
constexpr int Altium2KiCadUnit(const int val, const int frac)

References Altium2KiCadUnit(), and ALTIUM_PARSER::PropertiesReadInt().

Referenced by ASCH_ARC::ASCH_ARC(), ASCH_BEZIER::ASCH_BEZIER(), ASCH_BUS::ASCH_BUS(), ASCH_BUS_ENTRY::ASCH_BUS_ENTRY(), ASCH_COMPONENT::ASCH_COMPONENT(), ASCH_DESIGNATOR::ASCH_DESIGNATOR(), ASCH_FILE_NAME::ASCH_FILE_NAME(), ASCH_IMAGE::ASCH_IMAGE(), ASCH_JUNCTION::ASCH_JUNCTION(), ASCH_LABEL::ASCH_LABEL(), ASCH_LINE::ASCH_LINE(), ASCH_NET_LABEL::ASCH_NET_LABEL(), ASCH_NO_ERC::ASCH_NO_ERC(), ASCH_PARAMETER::ASCH_PARAMETER(), ASCH_POLYGON::ASCH_POLYGON(), ASCH_POLYLINE::ASCH_POLYLINE(), ASCH_PORT::ASCH_PORT(), ASCH_POWER_PORT::ASCH_POWER_PORT(), ASCH_RECTANGLE::ASCH_RECTANGLE(), ASCH_ROUND_RECTANGLE::ASCH_ROUND_RECTANGLE(), ASCH_SHEET_FONT::ASCH_SHEET_FONT(), ASCH_SHEET_NAME::ASCH_SHEET_NAME(), ASCH_SHEET_SYMBOL::ASCH_SHEET_SYMBOL(), ASCH_WIRE::ASCH_WIRE(), and BOOST_AUTO_TEST_CASE().

◆ PropertiesReadKiCadUnitFrac1()

int PropertiesReadKiCadUnitFrac1 ( const std::map< wxString, wxString > &  aProperties,
const wxString &  aKey 
)

Definition at line 57 of file altium_parser_sch.cpp.

59 {
60  // a unit is stored using two fields, denoting the size in mils and a fraction size
61  // Dunno why Altium invents different units for the same purpose
62  int key = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey, 0 );
63  int keyFrac = ALTIUM_PARSER::PropertiesReadInt( aProperties, aKey + "_FRAC1", 0 );
64  return Altium2KiCadUnit( key * 10, keyFrac );
65 }
static int PropertiesReadInt(const std::map< wxString, wxString > &aProperties, const wxString &aKey, int aDefault)
constexpr int Altium2KiCadUnit(const int val, const int frac)

References Altium2KiCadUnit(), and ALTIUM_PARSER::PropertiesReadInt().

Referenced by ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY().

◆ PropertiesReadRecord()