22#include <unordered_map>
44 constexpr double int_limit = ( std::numeric_limits<int>::max() - 10 ) / 2.54;
46 double dbase = 10 *
schIUScale.MilsToIU( val );
47 double dfrac =
schIUScale.MilsToIU( frac ) / 10000.0;
49 return KiROUND( std::clamp( ( dbase + dfrac ) / 10.0, -int_limit, int_limit ) ) * 10;
85T ReadEnum(
const std::map<wxString, wxString>& aProps,
const wxString& aKey,
int aLower,
86 int aUpper,
T aDefault )
90 if( value < aLower || value > aUpper )
93 return static_cast<T>( value );
103 const size_t charCount = hexData.size();
105 if( charCount != dataSize * 2 )
107 THROW_IO_ERROR( wxString::Format(
"Invalid binary file hex data size. Chars expected: %d, "
108 "hex string length: %d",
109 int( dataSize * 2 ),
int( hexData.size() ) ) );
112 data.resize( dataSize );
118 for(
size_t inputId = 1; inputId < charCount; inputId += 2 )
120 str[0] = (char) hexData[inputId - 1];
121 str[1] = (char) hexData[inputId];
123 std::from_chars( str, str + 2, b, 16 );
135 uint32_t dataSize = aReader.
Read<uint32_t>();
147 uint32_t dataSize = aReader.
Read<uint32_t>();
180 if( displayModeStr.ToCLong( &v ) )
223 hidden = ( pinconglomerate & 0x04 ) != 0;
227 locked = ( pinconglomerate & 0x40 ) != 0;
242 int kicadXfrac = xfrac;
244 int kicadYfrac = yfrac;
247 int offsetYfrac = pfrac;
253 kicadXfrac += offsetYfrac;
258 kicadYfrac += offsetYfrac;
263 kicadXfrac -= offsetYfrac;
268 kicadYfrac -= offsetYfrac;
272 wxLogWarning(
"Pin has unexpected orientation" );
351 Text.Replace(
"~1",
"\n",
true );
387 for(
int i = 1; i <= locationCount; i++ )
389 const wxString si = std::to_string( i );
404 for(
int i = 1; i <= locationCount; i++ )
406 const wxString si = std::to_string( i );
425 for(
int i = 1; i <= locationCount; i++ )
427 const wxString si = std::to_string( i );
518 for(
int i = 1; i <= locationCount; i++ )
520 const wxString si = std::to_string( i );
731 for(
int i = 1; i <= locationcount; i++ )
733 const wxString si = std::to_string( i );
749 for(
int i = 1; i <= locationcount; i++ )
751 const wxString si = std::to_string( i );
794 const wxString sid = std::to_string( aId );
844 for(
int i = 1; i <= fontidcount; i++ )
845 fonts.emplace_back( aProps, i );
int ReadOwnerPartId(const std::map< wxString, wxString > &aProperties)
int ReadOwnerIndex(const std::map< wxString, wxString > &aProperties)
T ReadEnum(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aLower, int aUpper, T aDefault)
constexpr int Altium2KiCadUnit(const int val, const int frac)
VECTOR2I ASchSheetGetSize(ASCH_SHEET_SIZE aSheetSize)
int ReadKiCadUnitFrac1(const std::map< wxString, wxString > &aProps, const wxString &aKey)
int ReadKiCadUnitFrac(const std::map< wxString, wxString > &aProps, const wxString &aKey)
ALTIUM_SCH_RECORD ReadRecord(const std::map< wxString, wxString > &aProps)
const int ALTIUM_COMPONENT_NONE
constexpr EDA_IU_SCALE schIUScale
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
void Skip(size_t aLength)
std::vector< char > ReadVector(size_t aSize)
static int ReadInt(const std::map< wxString, wxString > &aProps, const wxString &aKey, int aDefault)
static bool ReadBool(const std::map< wxString, wxString > &aProps, const wxString &aKey, bool aDefault)
static wxString ReadString(const std::map< wxString, wxString > &aProps, const wxString &aKey, const wxString &aDefault)
static double ReadDouble(const std::map< wxString, wxString > &aProps, const wxString &aKey, double aDefault)
static PTYPE FromInt(int aInt)
#define THROW_IO_ERROR(msg)
macro which captures the "call site" values of FILE_, __FUNCTION & LINE
ASCH_ADDITIONAL_FILE(ALTIUM_BINARY_PARSER &aReader)
ASCH_ARC(const std::map< wxString, wxString > &aProps)
ASCH_BEZIER(const std::map< wxString, wxString > &aProps)
std::vector< VECTOR2I > points
ASCH_BORDER_INTERFACE(const std::map< wxString, wxString > &aProps)
ASCH_BUS_ENTRY(const std::map< wxString, wxString > &aProps)
ASCH_BUS(const std::map< wxString, wxString > &aProps)
std::vector< VECTOR2I > points
ASCH_LABEL_JUSTIFICATION justification
ASCH_DESIGNATOR(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_ELLIPSE(const std::map< wxString, wxString > &aProps)
ASCH_FILE_NAME(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_FILL_INTERFACE(const std::map< wxString, wxString > &aProps)
ASCH_HARNESS_CONNECTOR(const std::map< wxString, wxString > &aProps)
int m_primaryConnectionPosition
ASCH_SHEET_ENTRY_SIDE m_harnessConnectorSide
ASCH_HARNESS_ENTRY(const std::map< wxString, wxString > &aProps)
ASCH_SHEET_ENTRY_SIDE Side
bool OwnerIndexAdditionalList
ASCH_HARNESS_TYPE(const std::map< wxString, wxString > &aProps)
bool OwnerIndexAdditionalList
ASCH_HYPERLINK(const std::map< wxString, wxString > &aProps)
ASCH_IMAGE(const std::map< wxString, wxString > &aProps)
ASCH_IMPLEMENTATION_LIST(const std::map< wxString, wxString > &aProps)
ASCH_IMPLEMENTATION(const std::map< wxString, wxString > &aProps)
ASCH_JUNCTION(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_LABEL(const std::map< wxString, wxString > &aProps)
ASCH_LABEL_JUSTIFICATION justification
ASCH_POLYLINE_LINESTYLE LineStyle
ASCH_LINE(const std::map< wxString, wxString > &aProps)
ASCH_LABEL_JUSTIFICATION justification
ASCH_RECORD_ORIENTATION orientation
ASCH_NET_LABEL(const std::map< wxString, wxString > &aProps)
ASCH_NOTE(const std::map< wxString, wxString > &aProperties)
ASCH_NO_ERC(const std::map< wxString, wxString > &aProps)
ASCH_OWNER_INTERFACE(const std::map< wxString, wxString > &aProps)
ASCH_PARAMETER(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_LABEL_JUSTIFICATION justification
ASCH_PIECHART(const std::map< wxString, wxString > &aProps)
ASCH_PIN_SYMBOL::PTYPE symbolOuterEdge
ASCH_PIN_SYMBOL::PTYPE symbolOuter
ASCH_PIN_ELECTRICAL electrical
ASCH_PIN_SYMBOL::PTYPE symbolInner
ASCH_PIN_SYMBOL::PTYPE symbolInnerEdge
ASCH_RECORD_ORIENTATION orientation
ASCH_PIN(const std::map< wxString, wxString > &aProps)
std::vector< VECTOR2I > points
ASCH_POLYGON(const std::map< wxString, wxString > &aProps)
ASCH_POLYLINE(const std::map< wxString, wxString > &aProps)
ASCH_POLYLINE_LINESTYLE LineStyle
std::vector< VECTOR2I > Points
ASCH_PORT(const std::map< wxString, wxString > &aProps)
ASCH_PORT_ALIGNMENT m_align
ASCH_POWER_PORT(const std::map< wxString, wxString > &aProps)
ASCH_POWER_PORT_STYLE style
ASCH_RECORD_ORIENTATION orientation
ASCH_RECTANGLE(const std::map< wxString, wxString > &aProps)
ASCH_ROUND_RECTANGLE(const std::map< wxString, wxString > &aProps)
ASCH_SHEET_ENTRY(const std::map< wxString, wxString > &aProps)
ASCH_SHEET_ENTRY_SIDE side
ASCH_SHEET_FONT(const std::map< wxString, wxString > &aProps, int aId)
ASCH_SHEET_NAME(const std::map< wxString, wxString > &aProps)
ASCH_RECORD_ORIENTATION orientation
ASCH_SHEET_SYMBOL(const std::map< wxString, wxString > &aProps)
ASCH_SHEET_SIZE sheetSize
ASCH_SHEET_WORKSPACEORIENTATION sheetOrientation
ASCH_SHEET(const std::map< wxString, wxString > &aProps)
std::vector< ASCH_SHEET_FONT > fonts
std::vector< VECTOR2I > points
ASCH_SIGNAL_HARNESS(const std::map< wxString, wxString > &aProps)
ASCH_STORAGE_FILE(const std::map< wxString, wxString > &aProps)
wxString componentdescription
ASCH_SYMBOL(const std::map< wxString, wxString > &aProps)
wxString sourcelibraryname
ASCH_TEMPLATE(const std::map< wxString, wxString > &aProps)
ASCH_TEXT_FRAME_ALIGNMENT Alignment
ASCH_TEXT_FRAME(const std::map< wxString, wxString > &aProps)
ASCH_WIRE(const std::map< wxString, wxString > &aProps)
std::vector< VECTOR2I > points
VECTOR2< int32_t > VECTOR2I