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 <wx/log.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 ReadRecord (const std::map< wxString, wxString > &aProps)
 
constexpr int Altium2KiCadUnit (const int val, const int frac)
 
int ReadKiCadUnitFrac (const std::map< wxString, wxString > &aProps, const wxString &aKey)
 
int ReadKiCadUnitFrac1 (const std::map< wxString, wxString > &aProps, const wxString &aKey)
 
int ReadOwnerIndex (const std::map< wxString, wxString > &aProperties)
 
int ReadOwnerPartId (const std::map< wxString, wxString > &aProperties)
 
template<typename T >
ReadEnum (const std::map< wxString, wxString > &aProps, 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 44 of file altium_parser_sch.cpp.

45 {
46  return Mils2iu( val ) * 10 + Mils2iu( frac ) / 10000; // TODO: correct, rounding issues?
47 }

Referenced by ASCH_PIN::ASCH_PIN(), ReadKiCadUnitFrac(), and ReadKiCadUnitFrac1().

◆ ASchSheetGetSize()

wxPoint ASchSheetGetSize ( ASCH_SHEET_SIZE  aSheetSize)

Definition at line 603 of file altium_parser_sch.cpp.

604 {
605  // From: https://github.com/vadmium/python-altium/blob/master/format.md#sheet
606  switch( aSheetSize )
607  {
608  default:
609  case ASCH_SHEET_SIZE::A4: return { 1150, 760 };
610  case ASCH_SHEET_SIZE::A3: return { 1550, 1110 };
611  case ASCH_SHEET_SIZE::A2: return { 2230, 1570 };
612  case ASCH_SHEET_SIZE::A1: return { 3150, 2230 };
613  case ASCH_SHEET_SIZE::A0: return { 4460, 3150 };
614  case ASCH_SHEET_SIZE::A: return { 950, 750 };
615  case ASCH_SHEET_SIZE::B: return { 1500, 950 };
616  case ASCH_SHEET_SIZE::C: return { 2000, 1500 };
617  case ASCH_SHEET_SIZE::D: return { 3200, 2000 };
618  case ASCH_SHEET_SIZE::E: return { 4200, 3200 };
619  case ASCH_SHEET_SIZE::LETTER: return { 1100, 850 };
620  case ASCH_SHEET_SIZE::LEGAL: return { 1400, 850 };
621  case ASCH_SHEET_SIZE::TABLOID: return { 1700, 1100 };
622  case ASCH_SHEET_SIZE::ORCAD_A: return { 990, 790 };
623  case ASCH_SHEET_SIZE::ORCAD_B: return { 1540, 990 };
624  case ASCH_SHEET_SIZE::ORCAD_C: return { 2060, 1560 };
625  case ASCH_SHEET_SIZE::ORCAD_D: return { 3260, 2060 };
626  case ASCH_SHEET_SIZE::ORCAD_E: return { 4280, 3280 };
627  }
628 }

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.

◆ ReadEnum()

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

Definition at line 82 of file altium_parser_sch.cpp.

84 {
85  int value = ALTIUM_PARSER::ReadInt( aProps, aKey, static_cast<int>( aDefault ));
86 
87  if( value < aLower || value > aUpper )
88  return aDefault;
89  else
90  return static_cast<T>( value );
91 }
static int ReadInt(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aDefault)

References ALTIUM_PARSER::ReadInt().

◆ ReadKiCadUnitFrac()

int ReadKiCadUnitFrac ( const std::map< wxString, wxString > &  aProps,
const wxString &  aKey 
)

◆ ReadKiCadUnitFrac1()

int ReadKiCadUnitFrac1 ( const std::map< wxString, wxString > &  aProps,
const wxString &  aKey 
)

Definition at line 59 of file altium_parser_sch.cpp.

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

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

Referenced by ASCH_SHEET_ENTRY::ASCH_SHEET_ENTRY().

◆ ReadOwnerIndex()

◆ ReadOwnerPartId()

◆ ReadRecord()