KiCad PCB EDA Suite
Loading...
Searching...
No Matches
orcad_cache.cpp File Reference
#include <sch_io/orcad/orcad_cache.h>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <set>
#include <ki_exception.h>
#include <wx/translation.h>
#include <sch_io/orcad/orcad_orient.h>

Go to the source code of this file.

Functions

std::optional< ORCAD_PRIMITIVE > OrcadReadPrimitive (ORCAD_STRUCT_READER &aReader)
 Consumes one primitive and its optional preamble.
 
std::optional< ORCAD_SYMBOL_PIN > OrcadReadSymbolPin (ORCAD_STRUCT_READER &aReader)
 A zero byte marks an empty pin slot and returns nullopt.
 
ORCAD_SYMBOL_DEF OrcadReadSymbolDef (ORCAD_STRUCT_READER &aReader, const ORCAD_PREFIXES &aPrefixes, bool aWithPins)
 Read a symbol definition body (LibraryPart / GlobalSymbol / PortSymbol / OffPageSymbol / TitleBlockSymbol / ERCSymbol / BookmarkSymbol / PinShapeSymbol).
 
ORCAD_DRAWN_INSTANCE OrcadReadDrawnInstance (ORCAD_STRUCT_READER &aReader, const ORCAD_PREFIXES &aPrefixes)
 
std::vector< ORCAD_BLOCK_PIN > OrcadResolveBlockPins (int aOrient, int aX1, int aY1, const ORCAD_SYMBOL_DEF &aDefinition, const std::vector< ORCAD_PIN_INST > &aPlaced)
 Pair placed pin records with the inline definition by pin index.
 
ORCAD_DEVICE OrcadReadDevice (ORCAD_STRUCT_READER &aReader)
 
ORCAD_PACKAGE OrcadReadPackage (ORCAD_STRUCT_READER &aReader, const ORCAD_PREFIXES &aPrefixes)
 
static void storeFramedRecord (ORCAD_STRUCT_READER &aReader, const ORCAD_PREFIXES &aPrefixes, std::map< std::string, ORCAD_SYMBOL_DEF > &aSymbols, std::map< std::string, ORCAD_PACKAGE > &aPackages)
 
static bool cacheSectionAcceptsType (int aSection, int aTypeId)
 
static std::string readLegacyLibraryPartTail (ORCAD_STREAM &aStream, ORCAD_SYMBOL_DEF &aDef)
 
static void storeLegacyCacheRecord (ORCAD_STRUCT_READER &aReader, int aTypeId, std::map< std::string, ORCAD_SYMBOL_DEF > &aSymbols, std::map< std::string, ORCAD_PACKAGE > &aPackages)
 
void OrcadParseCache (const std::vector< char > &aData, const std::vector< std::string > &aStrings, const ORCAD_WARN_FN &aWarn, std::map< std::string, ORCAD_SYMBOL_DEF > &aSymbols, std::map< std::string, ORCAD_PACKAGE > &aPackages, ORCAD_DIALECT aDialect)
 The first entry is the default; later entries become variants.
 
void OrcadParseSymbolStream (const std::vector< char > &aData, const std::vector< std::string > &aStrings, std::map< std::string, ORCAD_SYMBOL_DEF > &aSymbols, ORCAD_DIALECT aDialect)
 Throws IO_ERROR for invalid framing or trailing bytes.
 
void OrcadParsePackageStream (const std::vector< char > &aData, const std::vector< std::string > &aStrings, std::map< std::string, ORCAD_SYMBOL_DEF > &aSymbols, std::map< std::string, ORCAD_PACKAGE > &aPackages, ORCAD_DIALECT aDialect)
 Package streams contain counted PartCells and LibraryParts, followed by one Package.
 
void OrcadMergeCacheStreams (std::map< std::string, ORCAD_SYMBOL_DEF > &aSymbols, std::map< std::string, ORCAD_PACKAGE > &aPackages, std::map< std::string, ORCAD_SYMBOL_DEF > &&aExtraSymbols, std::map< std::string, ORCAD_PACKAGE > &&aExtraPackages)
 Merge the results of a 'Packages/<name>' stream (locally modified parts) into the main cache maps: a symbol name already present gains the extra entries as variants (the main cache definition stays the default); a new name is inserted as-is.
 
void OrcadMergeSymbolGeneralProperties (std::map< std::string, ORCAD_SYMBOL_DEF > &aSymbols, const std::map< std::string, ORCAD_SYMBOL_DEF > &aMetadataSymbols)
 

Function Documentation

◆ cacheSectionAcceptsType()

static bool cacheSectionAcceptsType ( int aSection,
int aTypeId )
static

Definition at line 806 of file orcad_cache.cpp.

References ORCAD_ST_LIBRARY_PART, ORCAD_ST_PACKAGE, and ORCAD_ST_PART_CELL.

Referenced by OrcadParseCache().

◆ OrcadMergeCacheStreams()

void OrcadMergeCacheStreams ( std::map< std::string, ORCAD_SYMBOL_DEF > & aSymbols,
std::map< std::string, ORCAD_PACKAGE > & aPackages,
std::map< std::string, ORCAD_SYMBOL_DEF > && aExtraSymbols,
std::map< std::string, ORCAD_PACKAGE > && aExtraPackages )

Merge the results of a 'Packages/<name>' stream (locally modified parts) into the main cache maps: a symbol name already present gains the extra entries as variants (the main cache definition stays the default); a new name is inserted as-is.

Packages are inserted only when the name is not already present.

Definition at line 1081 of file orcad_cache.cpp.

References name.

Referenced by SCH_IO_ORCAD::loadOlbSymbols(), and SCH_IO_ORCAD::LoadSchematicFile().

◆ OrcadMergeSymbolGeneralProperties()

void OrcadMergeSymbolGeneralProperties ( std::map< std::string, ORCAD_SYMBOL_DEF > & aSymbols,
const std::map< std::string, ORCAD_SYMBOL_DEF > & aMetadataSymbols )

Definition at line 1131 of file orcad_cache.cpp.

References name.

Referenced by SCH_IO_ORCAD::LoadSchematicFile().

◆ OrcadParseCache()

void OrcadParseCache ( const std::vector< char > & aData,
const std::vector< std::string > & aStrings,
const ORCAD_WARN_FN & aWarn,
std::map< std::string, ORCAD_SYMBOL_DEF > & aSymbols,
std::map< std::string, ORCAD_PACKAGE > & aPackages,
ORCAD_DIALECT aDialect = {} )

◆ OrcadParsePackageStream()

void OrcadParsePackageStream ( const std::vector< char > & aData,
const std::vector< std::string > & aStrings,
std::map< std::string, ORCAD_SYMBOL_DEF > & aSymbols,
std::map< std::string, ORCAD_PACKAGE > & aPackages,
ORCAD_DIALECT aDialect )

◆ OrcadParseSymbolStream()

void OrcadParseSymbolStream ( const std::vector< char > & aData,
const std::vector< std::string > & aStrings,
std::map< std::string, ORCAD_SYMBOL_DEF > & aSymbols,
ORCAD_DIALECT aDialect )

◆ OrcadReadDevice()

◆ OrcadReadDrawnInstance()

◆ OrcadReadPackage()

◆ OrcadReadPrimitive()

std::optional< ORCAD_PRIMITIVE > OrcadReadPrimitive ( ORCAD_STRUCT_READER & aReader)

Consumes one primitive and its optional preamble.

Throws IO_ERROR for invalid framing or length. Returns nullopt for a recognized body that is not supported.

Definition at line 363 of file orcad_cache.cpp.

References ORCAD_STRUCT_READER::Dialect(), ORCAD_STREAM::GetOffset(), ORCAD_DIALECT::legacy, ORCAD_PRIM_SYMBOL_VECTOR, ORCAD_STREAM::ReadU8(), ORCAD_STRUCT_READER::Stream(), and THROW_IO_ERRORF.

Referenced by OrcadReadSymbolDef().

◆ OrcadReadSymbolDef()

ORCAD_SYMBOL_DEF OrcadReadSymbolDef ( ORCAD_STRUCT_READER & aReader,
const ORCAD_PREFIXES & aPrefixes,
bool aWithPins )

Read a symbol definition body (LibraryPart / GlobalSymbol / PortSymbol / OffPageSymbol / TitleBlockSymbol / ERCSymbol / BookmarkSymbol / PinShapeSymbol).

Layout documented on ORCAD_SYMBOL_DEF, including the bbox rule: the box is the LAST 8 bytes before the next prefix stop (as 4 x i16), accepted only when x1 <= x2, y1 <= y2 and both spans are <= 4000 DBU.

Parameters
aReaderis the structure reader positioned at the body.
aPrefixesare the prefixes already read for this structure.
aWithPinsread the trailing u16 pin-count pin list and u16 property list (true for cache symbols, false for nested SthInPages0 bodies).

Definition at line 430 of file orcad_cache.cpp.

References ORCAD_SYMBOL_DEF::bbox, ORCAD_SYMBOL_DEF::color, ORCAD_STRUCT_READER::Dialect(), ORCAD_PREFIXES::end, ORCAD_SYMBOL_DEF::generalFlags, ORCAD_STREAM::GetOffset(), ORCAD_DIALECT::legacy, ORCAD_SYMBOL_DEF::name, ORCAD_ST_LIBRARY_PART, OrcadReadPrimitive(), OrcadReadSymbolPin(), ORCAD_STREAM::PeekMatches(), pin, ORCAD_SYMBOL_DEF::pins, ORCAD_SYMBOL_DEF::primitives, ORCAD_SYMBOL_DEF::props, ORCAD_STRUCT_READER::PropsDict(), ORCAD_STRUCT_READER::ReadCount(), ORCAD_STREAM::ReadI16(), ORCAD_STREAM::ReadLzt(), ORCAD_STRUCT_READER::ReadStructure(), ORCAD_STREAM::ReadU16(), ORCAD_STREAM::ReadU32(), save, ORCAD_STREAM::Seek(), ORCAD_DIALECT::shortDisplayProp, ORCAD_STREAM::Skip(), ORCAD_SYMBOL_DEF::sourceLib, ORCAD_PREFIXES::stops, ORCAD_STRUCT_READER::Stream(), ORCAD_PREFIXES::typeId, ORCAD_SYMBOL_DEF::typeId, ORCAD_BBOX::x1, ORCAD_BBOX::x2, ORCAD_BBOX::y1, and ORCAD_BBOX::y2.

Referenced by OrcadParsePackageStream(), OrcadParseSymbolStream(), OrcadReadDrawnInstance(), ORCAD_STRUCT_READER::ReadStructure(), storeFramedRecord(), and storeLegacyCacheRecord().

◆ OrcadReadSymbolPin()

◆ OrcadResolveBlockPins()

std::vector< ORCAD_BLOCK_PIN > OrcadResolveBlockPins ( int aOrient,
int aX1,
int aY1,
const ORCAD_SYMBOL_DEF & aDefinition,
const std::vector< ORCAD_PIN_INST > & aPlaced )

Pair placed pin records with the inline definition by pin index.

When every placed pin sits on one point, the definition pins are placed through the block orientation instead.

Definition at line 665 of file orcad_cache.cpp.

References std::abs(), ORCAD_SYMBOL_DEF::bbox, ORCAD_PIN_INST::IsNoConnect(), OrcadTransformPoint(), pin, ORCAD_PIN_INST::pinIndex, ORCAD_SYMBOL_DEF::pins, ORCAD_PIN_INST::x, VECTOR2< T >::x, ORCAD_BBOX::x1, ORCAD_BBOX::x2, ORCAD_PIN_INST::y, VECTOR2< T >::y, ORCAD_BBOX::y1, and ORCAD_BBOX::y2.

Referenced by OrcadReadDrawnInstance().

◆ readLegacyLibraryPartTail()

static std::string readLegacyLibraryPartTail ( ORCAD_STREAM & aStream,
ORCAD_SYMBOL_DEF & aDef )
static

◆ storeFramedRecord()

static void storeFramedRecord ( ORCAD_STRUCT_READER & aReader,
const ORCAD_PREFIXES & aPrefixes,
std::map< std::string, ORCAD_SYMBOL_DEF > & aSymbols,
std::map< std::string, ORCAD_PACKAGE > & aPackages )
static

◆ storeLegacyCacheRecord()