KiCad PCB EDA Suite
Loading...
Searching...
No Matches
ORCAD_CONVERTER Class Reference

Builds the KiCad schematic from a parsed OrCAD design. More...

#include <orcad_converter.h>

Classes

struct  LIB_ENTRY
 One emitted KiCad lib symbol (possibly multi-unit). More...
 
struct  OFFPAGE_NET
 One resolved off-page connector: index into page.offpage, net, pin position. More...
 
struct  UNIT_INFO
 One unit of an emitted multi-unit symbol. More...
 

Public Member Functions

 ORCAD_CONVERTER (ORCAD_DESIGN &aDesign, SCHEMATIC *aSchematic, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter=nullptr)
 
 ~ORCAD_CONVERTER ()
 Out-of-line: LIB_ENTRY holds LIB_SYMBOL by unique_ptr. [orcad_converter_sheet.cpp].
 
SCH_SHEETConvert (SCH_SHEET *aRootSheet)
 Populate the schematic.
 
std::vector< LIB_SYMBOL * > BuildSymbolLibrary ()
 Build KiCad library symbols from the design cache and packages alone (no schematic pages), for importing an OrCAD .OLB library.
 

Static Public Attributes

static constexpr const char * LIB_NICK = "orcad_import"
 Symbol library nickname used in every emitted LIB_ID.
 

Private Types

using PKG_KEY = std::tuple<std::string, std::string, int>
 (sourcePackage-or-pkgName, pkgName, variant index) -> (lib name, unit number).
 

Private Member Functions

void warn (const wxString &aMsg)
 Conversion problem: REPORTER at RPT_SEVERITY_WARNING.
 
void note (const wxString &aMsg)
 Fact about the source design (not a conversion problem): RPT_SEVERITY_INFO.
 
void prepareSymbols ()
 Pre-pass over all pages: synthesize placeholder definitions for symbols absent from the cache (one note per name), register a LIB_ENTRY + unit for every placed instance via libForInstance(), then computeFontBaseline().
 
ORCAD_SYMBOL_DEF synthesizeSymbol (const std::string &aPkgName, const std::vector< const ORCAD_PLACED_INSTANCE * > &aInstances) const
 Best-effort placeholder for a cache-less symbol, built from the instances' T0x10 absolute pin records and the placed bbox: rectangle body with pins on the sides where they actually sit.
 
std::string unitLetter (const ORCAD_PLACED_INSTANCE &aInst) const
 Unit discriminator of an instance: the part of pkgName between the package base name and the '.View' suffix ("A", "-16", "", ...), plus ":View" when the view is not "Normal" (DeMorgan variants).
 
std::pair< const ORCAD_SYMBOL_DEF *, int > pickVariant (const ORCAD_PLACED_INSTANCE &aInst) const
 The cache may hold several stale library versions of one symbol name; pick the variant whose transformed pin hot points match this instance's T0x10 records exactly (pin count must match too), else the first cache entry.
 
std::pair< std::string, int > libForInstance (const ORCAD_PLACED_INSTANCE &aInst)
 Resolve/register the emitted lib symbol and unit number for a placed part.
 
std::string powerLibFor (const std::string &aSymbolName, const std::string &aNetName)
 Resolve/register the power lib symbol for a power-symbol instance.
 
LIB_SYMBOLkicadSymbolFor (const std::string &aLibName)
 Return the fully built KiCad LIB_SYMBOL for a registered LIB_ENTRY, building and caching it on first use.
 
void addSymbolPrimitive (LIB_SYMBOL *aSymbol, const ORCAD_PRIMITIVE &aPrim, int aUnit, int aColor, int aOffsetX=0, int aOffsetY=0)
 Add one body primitive to a LIB_SYMBOL unit on LAYER_DEVICE.
 
void addSymbolArc (LIB_SYMBOL *aSymbol, const ORCAD_PRIMITIVE &aPrim, int aUnit, int aColor, int aOffsetX=0, int aOffsetY=0)
 Polyline approximation of an arc primitive. Helper of addSymbolPrimitive().
 
void addSymbolPin (LIB_SYMBOL *aSymbol, const ORCAD_SYMBOL_PIN &aPin, const wxString &aNumber, int aUnit, bool aPower, const std::string &aNameOverride)
 Add one pin: position = hot point, length = |start - hot|, orientation from the start-relative-to-hot direction, shape from shapeBits (bit 1 = clock, bit 2 = inverted dot), electrical type from portType (power symbols force power-in + hidden pin).
 
void placeInstance (ORCAD_RAW_PAGE &aPage, const ORCAD_PLACED_INSTANCE &aInst, SCH_SCREEN *aScreen, const SCH_SHEET_PATH &aSheetPath)
 Place one part instance on a screen: SCH_SYMBOL from the built LIB_SYMBOL (flattened-copy constructor route), position = anchor + orientation offset, orientation via toKicadOrientation(), fields via placeSymbolFields(), SetRef( aSheetPath, reference ), unit selection, then screen->Append.
 
wxString resolveReference (const ORCAD_PLACED_INSTANCE &aInst) const
 Resolve a placed instance's reference designator, falling back to the Hierarchy-stream occurrence designator when the instance carries only the unannotated "C?" template; returns "?" when neither is annotated.
 
void placePowerSymbol (ORCAD_RAW_PAGE &aPage, const ORCAD_GRAPHIC_INST &aInst, const std::string &aNet, SCH_SCREEN *aScreen, const SCH_SHEET_PATH &aSheetPath)
 Place one power symbol: transform base = placed bbox min corner (fall back to the anchor when the bbox is all zero), reference "#PWR%04d" from a design-wide counter (hidden), value = net name centered on the body — above it, or below it for ground-style symbols whose pin connects in the top quarter of the placed bbox.
 
void placeSymbolFields (SCH_SYMBOL *aSymbol, const ORCAD_PLACED_INSTANCE &aInst, const ORCAD_SYMBOL_DEF &aDef, int aOrient, const std::string &aValue, const std::string &aFootprint)
 KiCad-style field placement for a placed part, always reading horizontally (fields rotate with the symbol, so a 90/270-degree placement gets a compensating 90-degree field angle).
 
void computeFontBaseline ()
 Find the design's dominant text height (most frequent font height over all alias and display-prop font references); that height renders as KiCad's default 1.27 mm and every other height scales relative to it, so uniform designs come out uniform.
 
int fontHeightDbu (int aFontIdx) const
 |lfHeight| of a 1-based font index; 0 for invalid/default indices.
 
int textSizeIU (int aFontIdx) const
 Text size in IU for a font reference: 1.27 mm when the height is unknown; with a baseline, 1.27 mm * height / baseline clamped to [0.7, 5.0] mm; without a baseline, height * 25.4 * 0.75 / 96 mm with a 0.7 mm floor.
 
void applyFont (EDA_TEXT *aText, int aFontIdx) const
 
void convertPage (ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen, const SCH_SHEET_PATH &aSheetPath)
 Convert one page onto a screen: applyTitleBlock(), buildNetLookup(), then junctions, no-connects, bus entries, wires + alias labels, off-page connectors, ports, page graphics, part instances and power symbols.
 
void applyPageSettings (ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
 Fit the page and set the screen's PAGE_INFO.
 
void applyTitleBlock (const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
 Fill the screen TITLE_BLOCK from the first page title block carrying properties: Title, date ("Page Modify Date", else "Doc Date"), revision ("RevCode"), company ("OrgName"), comments ("Doc", "OrgAddr1", "OrgAddr2").
 
void buildNetLookup (const ORCAD_RAW_PAGE &aPage)
 Rebuild m_wireEndpoints for a page (both endpoints of every wire).
 
std::string netAt (const ORCAD_RAW_PAGE &aPage, int aX, int aY) const
 Net name at a point: first a wire with an endpoint here whose id is in the page net table; then any wire passing strictly through the point (id in table); then the first alias of an endpoint wire; else "".
 
std::string powerNet (const ORCAD_RAW_PAGE &aPage, const ORCAD_GRAPHIC_INST &aInst) const
 Net stamped by a power-symbol instance: the net of the wire its pin touches (authoritative — ports can be renamed), falling back to the symbol name.
 
VECTOR2I graphicPinPos (const ORCAD_GRAPHIC_INST &aInst) const
 Absolute connection point (DBU) of a GraphicInst-derived instance (power symbol / off-page connector / port): the cache symbol's first pin hot point transformed with base = placed bbox min corner (NOT the anchor).
 
std::vector< OFFPAGE_NEToffpageNets (const ORCAD_RAW_PAGE &aPage) const
 Resolve every off-page connector on the page to (index, net, pin position).
 
std::vector< VECTOR2IcomputeJunctions (const ORCAD_RAW_PAGE &aPage) const
 Junction points (DBU) from wire geometry + shared net ids.
 
void placeJunctions (const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
 Append computed junctions as SCH_JUNCTION items.
 
void placeWires (const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
 Wires/buses as SCH_LINE on LAYER_WIRE / LAYER_BUS, plus a local SCH_LABEL per wire alias: anchor snapped from the alias's free display position onto the owning wire segment (snapToWire) so KiCad binds it electrically; text angle 0/90 (source quadrants 2/3 fold onto 0/90); size from textSizeIU().
 
void placeBusEntries (const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
 SCH_BUS_WIRE_ENTRY per bus entry (position x1,y1; size x2-x1, y2-y1).
 
void placeNoConnects (const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
 SCH_NO_CONNECT per ERC object, at the object's anchor.
 
void placeOffpageConnectors (const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
 SCH_GLOBALLABEL per resolved off-page connector, at the connection point; an unconnected connector (empty net) is skipped with a note.
 
void placePorts (const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen, bool aHierarchical)
 SCH_HIERLABEL per port on a hierarchical child page, otherwise SCH_GLOBALLABEL.
 
void placeGraphics (const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
 Free page graphics from the nested primitives of each Graphic*Inst (the outer record itself is not drawable): comment text as SCH_TEXT (angle 0/90; quadrants 2/3 fold to 0), lines/rects/polylines/polygons/beziers as LAYER_NOTES polylines (rects closed, polygons closed), arcs/ellipses as polyline approximations, images via placeBitmap().
 
void placeBitmap (const ORCAD_PRIMITIVE &aPrim, SCH_SCREEN *aScreen, int aOrient=0)
 One image primitive -> SCH_BITMAP centered on the primitive's page extent, scaled from its native pixel size to the extent.
 
void placeDefinitionImages (const ORCAD_SYMBOL_DEF &aDefinition, int aBaseX, int aBaseY, int aOrient, SCH_SCREEN *aScreen)
 
void placeDefinitionVectors (const ORCAD_SYMBOL_DEF &aDefinition, int aBaseX, int aBaseY, int aOrient, SCH_SCREEN *aScreen)
 

Static Private Member Functions

static int toKicadOrientation (int aOrient)
 Map an orientation code to the composed SYMBOL_ORIENTATION_T value for SCH_SYMBOL::SetOrientation(): 0 -> SYM_ORIENT_0 4 -> SYM_ORIENT_0 + SYM_MIRROR_Y 1 -> SYM_ORIENT_90 5 -> SYM_ORIENT_90 + SYM_MIRROR_X 2 -> SYM_ORIENT_180 6 -> SYM_ORIENT_0 + SYM_MIRROR_X 3 -> SYM_ORIENT_270 7 -> SYM_ORIENT_270 + SYM_MIRROR_X.
 
static std::string SymbolId (const std::string &aName)
 LIB_ID-safe symbol name: ':', '"', '/' and whitespace runs -> '_'; "SYM" if empty.
 
static wxString MakePageFileName (int aPageIndex, const std::string &aPageName)
 "P%02d_<pagename>.kicad_sch" (1-based index), sanitized: control characters and the characters <>:"/|?
 
static BOX2I pageExtentDbu (const ORCAD_RAW_PAGE &aPage)
 Bounding box (DBU) of everything drawable on the page: wire ends, instance placed bboxes + T0x10 pin positions, anchor + bbox of ports/globals/ off-page/ERC objects, bus entries, block rectangles + pins, and — for free graphics — ONLY the nested primitives' coordinates (the outer bbox of a Graphic*Inst is anchor-relative junk).
 
static void offsetPage (ORCAD_RAW_PAGE &aPage, int aDx, int aDy)
 Shift every drawable coordinate on the page by (aDx, aDy) DBU: wires and their aliases, instances (anchor, bbox, pin positions), graphic instances (anchor, bbox, nested primitive coordinates including points/start/end), bus entries and blocks.
 
static bool MakeBmpFromDib (const std::vector< uint8_t > &aDib, wxMemoryBuffer &aOut)
 Synthesize a .BMP in front of a raw DIB (BITMAPINFOHEADER + optional palette + pixels): pixel data offset = 14 + biSize + 4 * paletteEntries (paletteEntries = biClrUsed, else 2^biBitCount when biBitCount <= 8, else 0) + 12 when biCompression == BI_BITFIELDS.
 
static VECTOR2I snapToWire (int aX, int aY, const ORCAD_WIRE &aWire)
 Closest point (DBU) on a wire segment to (aX, aY); exact for H/V wires.
 
static bool onSegment (int aX, int aY, const ORCAD_WIRE &aWire)
 True when the point lies strictly INSIDE (not at an endpoint of) an H/V wire.
 
static wxString SanitizeFileName (const std::string &aName)
 Filesystem-safe name: control characters and <>:"/|?
 

Private Attributes

ORCAD_DESIGNm_design
 
SCHEMATICm_schematic
 
REPORTERm_reporter
 
PROGRESS_REPORTERm_progressReporter
 
SCH_SHEETm_rootSheet
 
std::map< std::string, LIB_ENTRYm_libSymbols
 keyed by emitted lib name
 
std::map< PKG_KEY, std::pair< std::string, int > > m_pkgToLib
 
int m_powerCount
 "#PWR%04d" counter
 
int m_fontBaselineDbu
 dominant text height; 0 = none
 
const std::map< uint32_t, std::string > * m_currentOccRefs = nullptr
 Occurrence reference designators of the scope currently being converted; set per page so a child schematic reused by several block occurrences takes each occurrence's own designators.
 
std::set< wxString > m_usedSheetNames
 Lower-cased sheet names already emitted, to keep sibling sheet names unique.
 
std::map< std::pair< int, int >, std::vector< const ORCAD_WIRE * > > m_wireEndpoints
 Per-page wire lookup: endpoint -> wires ending there. Rebuilt by buildNetLookup().
 

Static Private Attributes

static constexpr int PIN_LEN_DBU = 10
 Standard OrCAD pin length used for synthesized placeholder pins, DBU.
 
static constexpr int MARGIN_L_DBU = 60
 Page content margins, DBU.
 
static constexpr int MARGIN_T_DBU = 60
 
static constexpr int MARGIN_R_DBU = 60
 
static constexpr int MARGIN_B_DBU = 100
 

Detailed Description

Builds the KiCad schematic from a parsed OrCAD design.

Usage (from SCH_IO_ORCAD::LoadSchematicFile, after the standard root-sheet / root-screen boilerplate):

ORCAD_CONVERTER converter( design, aSchematic, m_reporter, m_progressReporter );
converter.Convert( rootSheet );

The converter reports recoverable problems through the REPORTER (warnings for conversion issues, info notes for facts about the source design) and never aborts the import for a single bad record. It does NOT call UpdateAllScreenReferences() / FixupJunctionsAfterImport() — the plugin shell does that after Convert() returns.

Definition at line 198 of file orcad_converter.h.

Member Typedef Documentation

◆ PKG_KEY

using ORCAD_CONVERTER::PKG_KEY = std::tuple<std::string, std::string, int>
private

(sourcePackage-or-pkgName, pkgName, variant index) -> (lib name, unit number).

Definition at line 279 of file orcad_converter.h.

Constructor & Destructor Documentation

◆ ORCAD_CONVERTER()

ORCAD_CONVERTER::ORCAD_CONVERTER ( ORCAD_DESIGN & aDesign,
SCHEMATIC * aSchematic,
REPORTER * aReporter,
PROGRESS_REPORTER * aProgressReporter = nullptr )
Parameters
aDesignparsed design; held by reference and MUTATED during conversion (page-content shift, placeholder symbol insertion), so it must outlive the converter.

[orcad_converter_sheet.cpp]

Definition at line 166 of file orcad_converter_sheet.cpp.

References m_design, m_fontBaselineDbu, m_powerCount, m_progressReporter, m_reporter, m_rootSheet, and m_schematic.

◆ ~ORCAD_CONVERTER()

ORCAD_CONVERTER::~ORCAD_CONVERTER ( )
default

Member Function Documentation

◆ addSymbolArc()

void ORCAD_CONVERTER::addSymbolArc ( LIB_SYMBOL * aSymbol,
const ORCAD_PRIMITIVE & aPrim,
int aUnit,
int aColor,
int aOffsetX = 0,
int aOffsetY = 0 )
private

◆ addSymbolPin()

void ORCAD_CONVERTER::addSymbolPin ( LIB_SYMBOL * aSymbol,
const ORCAD_SYMBOL_PIN & aPin,
const wxString & aNumber,
int aUnit,
bool aPower,
const std::string & aNameOverride )
private

Add one pin: position = hot point, length = |start - hot|, orientation from the start-relative-to-hot direction, shape from shapeBits (bit 1 = clock, bit 2 = inverted dot), electrical type from portType (power symbols force power-in + hidden pin).

Pin name: aNameOverride when given, else the pin name unless empty or "$PIN"-prefixed or equal to the number (then "~").

Definition at line 1107 of file orcad_converter_symbols.cpp.

References LIB_SYMBOL::AddDrawItem(), CLOCK, FromOrcadString(), ORCAD_SYMBOL_PIN::hotptX, ORCAD_SYMBOL_PIN::hotptY, INVERTED, INVERTED_CLOCK, KiROUND(), LINE, name, ORCAD_SYMBOL_PIN::name, ORCAD_IU_PER_DBU, pin, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_UP, ORCAD_SYMBOL_PIN::portType, PT_POWER_IN, ORCAD_SYMBOL_PIN::shapeBits, ORCAD_SYMBOL_PIN::startX, and ORCAD_SYMBOL_PIN::startY.

Referenced by kicadSymbolFor().

◆ addSymbolPrimitive()

void ORCAD_CONVERTER::addSymbolPrimitive ( LIB_SYMBOL * aSymbol,
const ORCAD_PRIMITIVE & aPrim,
int aUnit,
int aColor,
int aOffsetX = 0,
int aOffsetY = 0 )
private

◆ applyFont()

◆ applyPageSettings()

void ORCAD_CONVERTER::applyPageSettings ( ORCAD_RAW_PAGE & aPage,
SCH_SCREEN * aScreen )
private

Fit the page and set the screen's PAGE_INFO.

Content is shifted clear of the frame: dx = max( 0, MARGIN_L - minX ), dy likewise for Y, both rounded UP to the 10-DBU grid (connectivity preserved), applied via offsetPage(). Paper size: nominal = stored page size converted to mm (mils * 0.0254, or um * 0.001 when isMetric); needed = (maxX + MARGIN_R, maxY + MARGIN_B) DBU

  • 0.254 mm; final = ceil of the max of both per axis, as a custom "User" page (PAGE_INFO::SetCustomWidthMils / SetCustomHeightMils then SetType).

Definition at line 610 of file orcad_converter_sheet.cpp.

References BOX2< Vec >::GetBottom(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), ORCAD_RAW_PAGE::height, ORCAD_RAW_PAGE::isMetric, MARGIN_B_DBU, MARGIN_L_DBU, MARGIN_R_DBU, MARGIN_T_DBU, offsetPage(), pageExtentDbu(), PAGE_INFO::SetCustomHeightMils(), PAGE_INFO::SetCustomWidthMils(), SCH_SCREEN::SetPageSettings(), PAGE_INFO::SetType(), User, and ORCAD_RAW_PAGE::width.

Referenced by Convert().

◆ applyTitleBlock()

void ORCAD_CONVERTER::applyTitleBlock ( const ORCAD_RAW_PAGE & aPage,
SCH_SCREEN * aScreen )
private

◆ buildNetLookup()

void ORCAD_CONVERTER::buildNetLookup ( const ORCAD_RAW_PAGE & aPage)
private

Rebuild m_wireEndpoints for a page (both endpoints of every wire).

Definition at line 1028 of file orcad_converter_sheet.cpp.

References m_wireEndpoints, ORCAD_RAW_PAGE::wires, ORCAD_WIRE::x1, ORCAD_WIRE::x2, ORCAD_WIRE::y1, and ORCAD_WIRE::y2.

Referenced by convertPage().

◆ BuildSymbolLibrary()

std::vector< LIB_SYMBOL * > ORCAD_CONVERTER::BuildSymbolLibrary ( )

Build KiCad library symbols from the design cache and packages alone (no schematic pages), for importing an OrCAD .OLB library.

One entry per package (multi-unit from its devices), plus any cache symbol not owned by a package. The returned symbols are owned by the caller. [orcad_converter_symbols.cpp]

Definition at line 236 of file orcad_converter_symbols.cpp.

References computeFontBaseline(), ORCAD_PACKAGE::devices, ORCAD_CONVERTER::LIB_ENTRY::footprint, ORCAD_CONVERTER::LIB_ENTRY::isPower, kicadSymbolFor(), m_design, m_libSymbols, ORCAD_CONVERTER::LIB_ENTRY::name, ORCAD_ST_GLOBAL_SYMBOL, ORCAD_ST_LIBRARY_PART, ORCAD_PACKAGE::pcbFootprint, ORCAD_CONVERTER::LIB_ENTRY::powerNet, ORCAD_PACKAGE::refDes, ORCAD_CONVERTER::LIB_ENTRY::refPrefix, SymbolId(), and ORCAD_CONVERTER::LIB_ENTRY::units.

Referenced by SCH_IO_ORCAD::loadOlbSymbols().

◆ computeFontBaseline()

void ORCAD_CONVERTER::computeFontBaseline ( )
private

Find the design's dominant text height (most frequent font height over all alias and display-prop font references); that height renders as KiCad's default 1.27 mm and every other height scales relative to it, so uniform designs come out uniform.

0 when the design has no font references.

Definition at line 1605 of file orcad_converter_symbols.cpp.

References ORCAD_WIRE::aliases, ORCAD_PLACED_INSTANCE::displayProps, fontHeightDbu(), ORCAD_ALIAS::fontIdx, ORCAD_DISPLAY_PROP::fontIdx, ORCAD_RAW_PAGE::instances, m_design, m_fontBaselineDbu, and ORCAD_RAW_PAGE::wires.

Referenced by BuildSymbolLibrary(), and prepareSymbols().

◆ computeJunctions()

std::vector< VECTOR2I > ORCAD_CONVERTER::computeJunctions ( const ORCAD_RAW_PAGE & aPage) const
private

Junction points (DBU) from wire geometry + shared net ids.

For every candidate point (wire endpoints and T0x10/block pin positions) count wire ends end, wires passing strictly through through, and pin presence pin (0/1); a junction is needed when end + 2*through + pin >= 3 AND end + pin >= 1 AND end + through >= 2 (three or more connection contributions meet, at least one terminating here).

Definition at line 1164 of file orcad_converter_sheet.cpp.

References ORCAD_RAW_PAGE::blocks, end, ORCAD_RAW_PAGE::instances, onSegment(), pin, ORCAD_DRAWN_INSTANCE::pins, ORCAD_PLACED_INSTANCE::pins, ORCAD_RAW_PAGE::wires, ORCAD_WIRE::x1, ORCAD_WIRE::x2, ORCAD_WIRE::y1, and ORCAD_WIRE::y2.

Referenced by placeJunctions().

◆ Convert()

SCH_SHEET * ORCAD_CONVERTER::Convert ( SCH_SHEET * aRootSheet)

Populate the schematic.

[orcad_converter_sheet.cpp]

Parameters
aRootSheetthe top-level sheet, already registered on the SCHEMATIC with a screen attached and the sheet UUID set to the screen UUID (the standard importer boilerplate).
Returns
aRootSheet.

Steps:

  1. prepareSymbols() — placeholders, lib-entry registration, font baseline.
  2. An unambiguous Capture hierarchy becomes KiCad sheets at the source block positions, with source sheet pins and hierarchical labels. Otherwise, pages become separate top-level sheets in source page order.
  3. Per page: applyPageSettings(), then convertPage() with the page's SCH_SHEET_PATH (references are set against that path).

Polls the PROGRESS_REPORTER (when present) once per page; a cancel throws IO_ERROR.

Definition at line 253 of file orcad_converter_sheet.cpp.

References std::abs(), SCH_SHEET::AddPin(), applyPageSettings(), BIDIRECTIONAL, ORCAD_RAW_PAGE::blocks, BOTTOM, ORCAD_OCC_BLOCK::childFolder, convertPage(), FromOrcadString(), SCH_SHEET::GetField(), SCH_SHEET::GetScreen(), SCH_SCREEN::GetUuid(), INPUT, L_BIDI, L_INPUT, L_OUTPUT, L_TRISTATE, L_UNSPECIFIED, LEFT, m_currentOccRefs, m_design, m_progressReporter, m_rootSheet, m_schematic, m_usedSheetNames, EDA_ITEM::m_Uuid, MakePageFileName(), name, ORCAD_BLOCK_PIN::name, ORCAD_RAW_PAGE::name, OrcadDbuToIu(), OrcadPageOrder(), OUTPUT, ORCAD_OCC_SCOPE::partRefs, pin, ORCAD_BLOCK_PIN::portType, prepareSymbols(), SCH_SHEET_PATH::push_back(), RIGHT, ORCAD_OCC_BLOCK::scope, SCH_SCREEN::SetFileName(), SCH_SHEET_PATH::SetPageNumber(), SCH_SHEET::SetScreen(), SCH_FIELD::SetText(), SHEET_FILENAME, SHEET_NAME, ORCAD_OCC_BLOCK::targetDbId, TOP, TRI_STATE, ORCAD_BLOCK_PIN::x, and ORCAD_BLOCK_PIN::y.

Referenced by SCH_IO_ORCAD::LoadSchematicFile().

◆ convertPage()

void ORCAD_CONVERTER::convertPage ( ORCAD_RAW_PAGE & aPage,
SCH_SCREEN * aScreen,
const SCH_SHEET_PATH & aSheetPath )
private

Convert one page onto a screen: applyTitleBlock(), buildNetLookup(), then junctions, no-connects, bus entries, wires + alias labels, off-page connectors, ports, page graphics, part instances and power symbols.

Definition at line 550 of file orcad_converter_sheet.cpp.

References applyTitleBlock(), buildNetLookup(), ORCAD_RAW_PAGE::globals, ORCAD_RAW_PAGE::instances, placeBusEntries(), placeGraphics(), placeInstance(), placeJunctions(), placeNoConnects(), placeOffpageConnectors(), placePorts(), placePowerSymbol(), placeWires(), powerNet(), and SCH_SHEET_PATH::size().

Referenced by Convert().

◆ fontHeightDbu()

int ORCAD_CONVERTER::fontHeightDbu ( int aFontIdx) const
private

|lfHeight| of a 1-based font index; 0 for invalid/default indices.

Definition at line 1658 of file orcad_converter_symbols.cpp.

References std::abs(), and m_design.

Referenced by computeFontBaseline(), and textSizeIU().

◆ graphicPinPos()

VECTOR2I ORCAD_CONVERTER::graphicPinPos ( const ORCAD_GRAPHIC_INST & aInst) const
private

Absolute connection point (DBU) of a GraphicInst-derived instance (power symbol / off-page connector / port): the cache symbol's first pin hot point transformed with base = placed bbox min corner (NOT the anchor).

Falls back to the anchor when the symbol or its pins are unknown.

Definition at line 1110 of file orcad_converter_sheet.cpp.

References ORCAD_GRAPHIC_INST::bbox, ORCAD_SYMBOL_DEF::bbox, m_design, ORCAD_GRAPHIC_INST::mirror, ORCAD_GRAPHIC_INST::name, OrcadOrientOf(), OrcadTransformPoint(), pin, ORCAD_SYMBOL_DEF::pins, ORCAD_GRAPHIC_INST::rotation, ORCAD_GRAPHIC_INST::x, ORCAD_BBOX::x1, ORCAD_BBOX::x2, ORCAD_GRAPHIC_INST::y, ORCAD_BBOX::y1, and ORCAD_BBOX::y2.

Referenced by offpageNets(), placePorts(), placePowerSymbol(), and powerNet().

◆ kicadSymbolFor()

LIB_SYMBOL * ORCAD_CONVERTER::kicadSymbolFor ( const std::string & aLibName)
private

Return the fully built KiCad LIB_SYMBOL for a registered LIB_ENTRY, building and caching it on first use.

The symbol gets SetName + SetLibId (LIB_NICK nickname), unit count from the entry, per-unit body graphics and pins (Y-down, same as the cache definition space), and KiCad-style field defaults: Reference = refPrefix (power: "#PWR", hidden), Value = lib name (power: net name), hidden Footprint/Datasheet. Power symbols get SetGlobalPower() and a single invisible power-input pin named after the net.

Definition at line 781 of file orcad_converter_symbols.cpp.

References addSymbolPin(), addSymbolPrimitive(), ORCAD_SYMBOL_DEF::bbox, ORCAD_SYMBOL_DEF::color, LIB_ID::FixIllegalChars(), FromOrcadString(), ORCAD_SYMBOL_DEF::generalFlags, ORCAD_CONVERTER::LIB_ENTRY::isPower, ORCAD_CONVERTER::LIB_ENTRY::kicadSymbol, LIB_NICK, m_libSymbols, name, ORCAD_CONVERTER::LIB_ENTRY::name, ORCAD_SYMBOL_PIN::name, ORCAD_IU_PER_DBU, ORCAD_CONVERTER::UNIT_INFO::pinNumbers, ORCAD_SYMBOL_DEF::pins, ORCAD_CONVERTER::LIB_ENTRY::powerNet, ORCAD_SYMBOL_DEF::primitives, ORCAD_CONVERTER::LIB_ENTRY::refPrefix, SCH_FIELD::SetText(), EDA_TEXT::SetTextPos(), EDA_TEXT::SetVisible(), ORCAD_CONVERTER::UNIT_INFO::symbol, ORCAD_CONVERTER::LIB_ENTRY::units, UTF8::wx_str(), and ORCAD_BBOX::y1.

Referenced by BuildSymbolLibrary(), placeInstance(), and placePowerSymbol().

◆ libForInstance()

std::pair< std::string, int > ORCAD_CONVERTER::libForInstance ( const ORCAD_PLACED_INSTANCE & aInst)
private

Resolve/register the emitted lib symbol and unit number for a placed part.

Lib name = sanitized package base name, with "_v<n+1>" appended for variant index n >= 1. Unit letters sort alphabetically and define the 1-based unit numbers; inserting a new letter renumbers, so stale PKG_KEY map entries for the lib are rebuilt. Pin numbers come from the package device whose unitRef equals the BARE unit letter (':View' suffix stripped — DeMorgan views share the Normal view's pin map); an instance without a cached symbol gets a placeholder (with warning).

Returns
(lib name, unit number).

Definition at line 597 of file orcad_converter_symbols.cpp.

References _, ORCAD_PACKAGE::devices, ORCAD_CONVERTER::LIB_ENTRY::footprint, FromOrcadString(), ORCAD_CONVERTER::UNIT_INFO::letter, m_design, m_libSymbols, m_pkgToLib, ORCAD_CONVERTER::LIB_ENTRY::name, ORCAD_SYMBOL_DEF::name, ORCAD_PACKAGE::pcbFootprint, pickVariant(), ORCAD_CONVERTER::UNIT_INFO::pinNumbers, ORCAD_DEVICE::pinNumbers, ORCAD_PLACED_INSTANCE::pkgName, ORCAD_PACKAGE::refDes, ORCAD_PLACED_INSTANCE::reference, ORCAD_CONVERTER::LIB_ENTRY::refPrefix, ORCAD_PLACED_INSTANCE::sourcePackage, ORCAD_CONVERTER::UNIT_INFO::symbol, SymbolId(), ORCAD_SYMBOL_DEF::typeId, unitLetter(), ORCAD_DEVICE::unitRef, ORCAD_CONVERTER::LIB_ENTRY::units, and warn().

Referenced by placeInstance(), and prepareSymbols().

◆ MakeBmpFromDib()

bool ORCAD_CONVERTER::MakeBmpFromDib ( const std::vector< uint8_t > & aDib,
wxMemoryBuffer & aOut )
staticprivate

Synthesize a .BMP in front of a raw DIB (BITMAPINFOHEADER + optional palette + pixels): pixel data offset = 14 + biSize + 4 * paletteEntries (paletteEntries = biClrUsed, else 2^biBitCount when biBitCount <= 8, else 0) + 12 when biCompression == BI_BITFIELDS.

Rejects headers with biSize < 40 or > 200.

Returns
false when the DIB is not usable.

Definition at line 1647 of file orcad_converter_sheet.cpp.

References header.

Referenced by placeBitmap().

◆ MakePageFileName()

wxString ORCAD_CONVERTER::MakePageFileName ( int aPageIndex,
const std::string & aPageName )
staticprivate

"P%02d_<pagename>.kicad_sch" (1-based index), sanitized: control characters and the characters <>:"/|?

  • replaced by '_', leading/trailing spaces and dots stripped, "unnamed" when empty; then ReplaceIllegalFileNameChars.

Definition at line 572 of file orcad_converter_sheet.cpp.

References ReplaceIllegalFileNameChars(), and SanitizeFileName().

Referenced by Convert().

◆ netAt()

std::string ORCAD_CONVERTER::netAt ( const ORCAD_RAW_PAGE & aPage,
int aX,
int aY ) const
private

Net name at a point: first a wire with an endpoint here whose id is in the page net table; then any wire passing strictly through the point (id in table); then the first alias of an endpoint wire; else "".

Definition at line 1040 of file orcad_converter_sheet.cpp.

References ORCAD_WIRE::aliases, ORCAD_WIRE::id, m_wireEndpoints, ORCAD_ALIAS::name, ORCAD_RAW_PAGE::netmap, onSegment(), and ORCAD_RAW_PAGE::wires.

Referenced by offpageNets(), and powerNet().

◆ note()

void ORCAD_CONVERTER::note ( const wxString & aMsg)
private

Fact about the source design (not a conversion problem): RPT_SEVERITY_INFO.

Definition at line 189 of file orcad_converter_sheet.cpp.

References m_reporter, and RPT_SEVERITY_INFO.

Referenced by placeInstance(), placeOffpageConnectors(), and prepareSymbols().

◆ offpageNets()

std::vector< ORCAD_CONVERTER::OFFPAGE_NET > ORCAD_CONVERTER::offpageNets ( const ORCAD_RAW_PAGE & aPage) const
private

◆ offsetPage()

◆ onSegment()

bool ORCAD_CONVERTER::onSegment ( int aX,
int aY,
const ORCAD_WIRE & aWire )
staticprivate

True when the point lies strictly INSIDE (not at an endpoint of) an H/V wire.

Definition at line 1734 of file orcad_converter_sheet.cpp.

References ORCAD_WIRE::x1, ORCAD_WIRE::x2, ORCAD_WIRE::y1, and ORCAD_WIRE::y2.

Referenced by computeJunctions(), and netAt().

◆ pageExtentDbu()

BOX2I ORCAD_CONVERTER::pageExtentDbu ( const ORCAD_RAW_PAGE & aPage)
staticprivate

◆ pickVariant()

std::pair< const ORCAD_SYMBOL_DEF *, int > ORCAD_CONVERTER::pickVariant ( const ORCAD_PLACED_INSTANCE & aInst) const
private

The cache may hold several stale library versions of one symbol name; pick the variant whose transformed pin hot points match this instance's T0x10 records exactly (pin count must match too), else the first cache entry.

Returns
(definition, variant index); (nullptr, 0) when the name is uncached.

Definition at line 546 of file orcad_converter_symbols.cpp.

References ORCAD_SYMBOL_DEF::bbox, m_design, ORCAD_PLACED_INSTANCE::mirror, OrcadOrientOf(), OrcadTransformPoint(), ORCAD_PLACED_INSTANCE::pins, ORCAD_SYMBOL_DEF::pins, ORCAD_PLACED_INSTANCE::pkgName, ORCAD_PLACED_INSTANCE::rotation, ORCAD_SYMBOL_DEF::variants, ORCAD_PLACED_INSTANCE::x, VECTOR2< T >::x, ORCAD_BBOX::x1, ORCAD_BBOX::x2, ORCAD_PLACED_INSTANCE::y, VECTOR2< T >::y, ORCAD_BBOX::y1, and ORCAD_BBOX::y2.

Referenced by libForInstance().

◆ placeBitmap()

void ORCAD_CONVERTER::placeBitmap ( const ORCAD_PRIMITIVE & aPrim,
SCH_SCREEN * aScreen,
int aOrient = 0 )
private

One image primitive -> SCH_BITMAP centered on the primitive's page extent, scaled from its native pixel size to the extent.

Plain DIB payloads have a BMP file header synthesized in front of them (see MakeBmpFromDib). OLE payloads use their native bitmap or rasterized WMF preview. Undecodable payloads are skipped with a warning. Extents smaller than 2 DBU or empty payloads are ignored.

Definition at line 1569 of file orcad_converter_sheet.cpp.

References _, std::abs(), ORCAD_ORIENT_ENTRY::angle, SCH_SCREEN::Append(), BMP, center, ORCAD_OLE_PREVIEW::data, ORCAD_PRIMITIVE::data, DIB, REFERENCE_IMAGE::GetSize(), image, MakeBmpFromDib(), ORCAD_ORIENT_ENTRY::mirror, ORCAD_IU_PER_DBU, ORCAD_ORIENT_TABLE, OrcadExtractOlePreview(), OrcadRenderWmf(), REFERENCE_IMAGE::ReadImageFile(), REFERENCE_IMAGE::SetImage(), REFERENCE_IMAGE::SetImageScale(), ORCAD_OLE_PREVIEW::type, warn(), WMF, VECTOR2< T >::x, ORCAD_PRIMITIVE::x1, ORCAD_PRIMITIVE::x2, VECTOR2< T >::y, ORCAD_PRIMITIVE::y1, and ORCAD_PRIMITIVE::y2.

Referenced by placeDefinitionImages(), and placeGraphics().

◆ placeBusEntries()

◆ placeDefinitionImages()

void ORCAD_CONVERTER::placeDefinitionImages ( const ORCAD_SYMBOL_DEF & aDefinition,
int aBaseX,
int aBaseY,
int aOrient,
SCH_SCREEN * aScreen )
private

◆ placeDefinitionVectors()

◆ placeGraphics()

void ORCAD_CONVERTER::placeGraphics ( const ORCAD_RAW_PAGE & aPage,
SCH_SCREEN * aScreen )
private

◆ placeInstance()

void ORCAD_CONVERTER::placeInstance ( ORCAD_RAW_PAGE & aPage,
const ORCAD_PLACED_INSTANCE & aInst,
SCH_SCREEN * aScreen,
const SCH_SHEET_PATH & aSheetPath )
private

Place one part instance on a screen: SCH_SYMBOL from the built LIB_SYMBOL (flattened-copy constructor route), position = anchor + orientation offset, orientation via toKicadOrientation(), fields via placeSymbolFields(), SetRef( aSheetPath, reference ), unit selection, then screen->Append.

Verifies the transformed pin hot points against the instance's T0x10 records: mismatch is a warning (note when the definition is synthesized).

Definition at line 1195 of file orcad_converter_symbols.cpp.

References _, SCH_SCREEN::Append(), ORCAD_SYMBOL_DEF::bbox, LIB_ID::FixIllegalChars(), ORCAD_CONVERTER::LIB_ENTRY::footprint, FromOrcadString(), kicadSymbolFor(), LIB_NICK, libForInstance(), m_libSymbols, ORCAD_PLACED_INSTANCE::mirror, ORCAD_CONVERTER::LIB_ENTRY::name, ORCAD_RAW_PAGE::name, note(), OrcadDbuToIu(), OrcadOrientOf(), OrcadOrientOffset(), OrcadTransformPoint(), pin, ORCAD_PLACED_INSTANCE::pins, ORCAD_SYMBOL_DEF::pins, placeDefinitionImages(), placeSymbolFields(), ORCAD_PLACED_INSTANCE::props, ORCAD_PLACED_INSTANCE::reference, resolveReference(), ORCAD_PLACED_INSTANCE::rotation, SCH_SYMBOL::SetExcludedFromBoard(), SCH_SYMBOL::SetOrientation(), SCH_SYMBOL::SetRef(), SCH_SYMBOL::SetUnitSelection(), ORCAD_CONVERTER::UNIT_INFO::symbol, ORCAD_SYMBOL_DEF::synthesized, toKicadOrientation(), ORCAD_CONVERTER::LIB_ENTRY::units, ORCAD_PLACED_INSTANCE::value, warn(), ORCAD_PLACED_INSTANCE::x, VECTOR2< T >::x, ORCAD_BBOX::x1, ORCAD_BBOX::x2, ORCAD_PLACED_INSTANCE::y, VECTOR2< T >::y, ORCAD_BBOX::y1, and ORCAD_BBOX::y2.

Referenced by convertPage().

◆ placeJunctions()

void ORCAD_CONVERTER::placeJunctions ( const ORCAD_RAW_PAGE & aPage,
SCH_SCREEN * aScreen )
private

Append computed junctions as SCH_JUNCTION items.

Definition at line 1219 of file orcad_converter_sheet.cpp.

References SCH_SCREEN::Append(), computeJunctions(), and OrcadDbuToIu().

Referenced by convertPage().

◆ placeNoConnects()

void ORCAD_CONVERTER::placeNoConnects ( const ORCAD_RAW_PAGE & aPage,
SCH_SCREEN * aScreen )
private

SCH_NO_CONNECT per ERC object, at the object's anchor.

Definition at line 1285 of file orcad_converter_sheet.cpp.

References SCH_SCREEN::Append(), erc, ORCAD_RAW_PAGE::ercObjects, and OrcadDbuToIu().

Referenced by convertPage().

◆ placeOffpageConnectors()

void ORCAD_CONVERTER::placeOffpageConnectors ( const ORCAD_RAW_PAGE & aPage,
SCH_SCREEN * aScreen )
private

SCH_GLOBALLABEL per resolved off-page connector, at the connection point; an unconnected connector (empty net) is skipped with a note.

Spin: with a wire endpoint at the point, the label points away from the wire (x1 + x2 - 2*px <= 0 selects the angle-0 spin, else angle-180); hide the INTERSHEET_REFS field.

Definition at line 1292 of file orcad_converter_sheet.cpp.

References _, std::abs(), SCH_SCREEN::Append(), SPIN_STYLE::BOTTOM, FromOrcadString(), SCH_GLOBALLABEL::GetField(), INTERSHEET_REFS, L_BIDI, SPIN_STYLE::LEFT, m_wireEndpoints, ORCAD_RAW_PAGE::name, note(), ORCAD_RAW_PAGE::offpage, offpageNets(), OrcadColor(), OrcadDbuToIu(), SPIN_STYLE::RIGHT, SCH_LABEL_BASE::SetShape(), SCH_GLOBALLABEL::SetSpinStyle(), EDA_TEXT::SetTextColor(), SPIN_STYLE::UP, ORCAD_WIRE::x1, ORCAD_WIRE::x2, ORCAD_WIRE::y1, and ORCAD_WIRE::y2.

Referenced by convertPage().

◆ placePorts()

void ORCAD_CONVERTER::placePorts ( const ORCAD_RAW_PAGE & aPage,
SCH_SCREEN * aScreen,
bool aHierarchical )
private

SCH_HIERLABEL per port on a hierarchical child page, otherwise SCH_GLOBALLABEL.

Net = logical name, else the symbol name; empty nets are skipped. Shape: "LEFT" in the symbol name -> input, "RIGHT" -> output, else bidirectional.

Definition at line 1335 of file orcad_converter_sheet.cpp.

References SCH_SCREEN::Append(), ORCAD_GRAPHIC_INST::color, FromOrcadString(), graphicPinPos(), INTERSHEET_REFS, L_BIDI, L_INPUT, L_OUTPUT, ORCAD_GRAPHIC_INST::logicalName, ORCAD_GRAPHIC_INST::name, OrcadColor(), OrcadDbuToIu(), ORCAD_RAW_PAGE::ports, SPIN_STYLE::RIGHT, SCH_LABEL_BASE::SetShape(), SCH_LABEL_BASE::SetSpinStyle(), EDA_TEXT::SetTextColor(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by convertPage().

◆ placePowerSymbol()

void ORCAD_CONVERTER::placePowerSymbol ( ORCAD_RAW_PAGE & aPage,
const ORCAD_GRAPHIC_INST & aInst,
const std::string & aNet,
SCH_SCREEN * aScreen,
const SCH_SHEET_PATH & aSheetPath )
private

Place one power symbol: transform base = placed bbox min corner (fall back to the anchor when the bbox is all zero), reference "#PWR%04d" from a design-wide counter (hidden), value = net name centered on the body — above it, or below it for ground-style symbols whose pin connects in the top quarter of the placed bbox.

Definition at line 1333 of file orcad_converter_symbols.cpp.

References ANGLE_HORIZONTAL, ANGLE_VERTICAL, SCH_SCREEN::Append(), ORCAD_GRAPHIC_INST::bbox, ORCAD_SYMBOL_DEF::bbox, BOX2< Vec >::Centre(), DATASHEET, LIB_ID::FixIllegalChars(), FOOTPRINT, FromOrcadString(), SCH_SYMBOL::GetBodyBoundingBox(), BOX2< Vec >::GetBottom(), SCH_SYMBOL::GetField(), BOX2< Vec >::GetTop(), SYMBOL::GetTransform(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_V_ALIGN_BOTTOM, GR_TEXT_V_ALIGN_TOP, graphicPinPos(), kicadSymbolFor(), LIB_NICK, m_libSymbols, m_powerCount, ORCAD_GRAPHIC_INST::mirror, ORCAD_GRAPHIC_INST::name, OrcadDbuToIu(), OrcadOrientOf(), OrcadOrientOffset(), powerLibFor(), REFERENCE, ORCAD_GRAPHIC_INST::rotation, EDA_TEXT::SetHorizJustify(), SCH_SYMBOL::SetOrientation(), SCH_FIELD::SetPosition(), SCH_SYMBOL::SetRef(), EDA_TEXT::SetTextAngle(), SCH_SYMBOL::SetUnitSelection(), SCH_SYMBOL::SetValueFieldText(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), toKicadOrientation(), ORCAD_CONVERTER::LIB_ENTRY::units, VALUE, ORCAD_GRAPHIC_INST::x, VECTOR2< T >::x, ORCAD_BBOX::x1, ORCAD_BBOX::x2, ORCAD_GRAPHIC_INST::y, VECTOR2< T >::y, ORCAD_BBOX::y1, TRANSFORM::y1, and ORCAD_BBOX::y2.

Referenced by convertPage().

◆ placeSymbolFields()

void ORCAD_CONVERTER::placeSymbolFields ( SCH_SYMBOL * aSymbol,
const ORCAD_PLACED_INSTANCE & aInst,
const ORCAD_SYMBOL_DEF & aDef,
int aOrient,
const std::string & aValue,
const std::string & aFootprint )
private

KiCad-style field placement for a placed part, always reading horizontally (fields rotate with the symbol, so a 90/270-degree placement gets a compensating 90-degree field angle).

The true body box is derived from the symbol bbox + orientation transform (the placed bbox includes displayed text). Vertical two-pin passives (placement angle 0/180, exactly 2 pins, vertical pin span >= horizontal) get Reference/Value stacked to the right of the body, left-justified, centered on it; everything else gets Reference above and Value below, centered. Visibility follows the source: a field is shown only when the instance carries a display prop for it ("Part Reference" / "Value"). Value fallback: instance value, else the "Value" property, else the lib name. Footprint: "PCB Footprint" property, else the package footprint (hidden). Remaining properties become user fields — visible at their display-prop position (transformed to canvas) when displayed, hidden at the anchor otherwise; bookkeeping names ("Part Reference", "Reference", "Name", "Graphic", "Implementation", "Implementation Path", "Implementation Type", "Source Library", "Source Package", "Source Part") are dropped.

Definition at line 1420 of file orcad_converter_symbols.cpp.

References std::abs(), SCH_SYMBOL::AddField(), ANGLE_HORIZONTAL, ANGLE_VERTICAL, applyFont(), ORCAD_SYMBOL_DEF::bbox, ORCAD_DISPLAY_PROP::color, DATASHEET, ORCAD_PLACED_INSTANCE::displayProps, ORCAD_DISPLAY_PROP::dispMode, ORCAD_DISPLAY_PROP::fontIdx, FOOTPRINT, FromOrcadString(), SCH_SYMBOL::GetField(), SCH_SYMBOL::GetPosition(), SYMBOL::GetTransform(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_V_ALIGN_TOP, ORCAD_DISPLAY_PROP::name, ORCAD_IU_PER_DBU, ORCAD_ORIENT_TABLE, OrcadColor(), OrcadDbuToIu(), OrcadTransformPoint(), ORCAD_PLACED_INSTANCE::pins, ORCAD_SYMBOL_DEF::pins, ORCAD_PLACED_INSTANCE::props, REFERENCE, SCH_SYMBOL::SetFootprintFieldText(), EDA_TEXT::SetHorizJustify(), SCH_FIELD::SetPosition(), SCH_FIELD::SetText(), EDA_TEXT::SetTextAngle(), EDA_TEXT::SetTextColor(), EDA_TEXT::SetTextSize(), SCH_SYMBOL::SetValueFieldText(), EDA_TEXT::SetVertJustify(), EDA_TEXT::SetVisible(), textSizeIU(), USER, VALUE, ORCAD_DISPLAY_PROP::x, ORCAD_PLACED_INSTANCE::x, VECTOR2< T >::x, ORCAD_BBOX::x1, ORCAD_BBOX::x2, ORCAD_DISPLAY_PROP::y, ORCAD_PLACED_INSTANCE::y, VECTOR2< T >::y, ORCAD_BBOX::y1, TRANSFORM::y1, and ORCAD_BBOX::y2.

Referenced by placeInstance().

◆ placeWires()

◆ powerLibFor()

std::string ORCAD_CONVERTER::powerLibFor ( const std::string & aSymbolName,
const std::string & aNetName )
private

Resolve/register the power lib symbol for a power-symbol instance.

Power lib symbols are keyed by NET name — "PWR_" + sanitized net — because users rename power ports (e.g. a VCC_BAR symbol naming the net +3V3); the graphics come from the named cache symbol (empty definition when uncached). The entry has isPower = true, powerNet = aNetName, refPrefix = "#PWR" and a single unit with pin number "1".

Returns
the lib name.

Definition at line 735 of file orcad_converter_symbols.cpp.

References ORCAD_CONVERTER::LIB_ENTRY::isPower, m_design, m_libSymbols, ORCAD_CONVERTER::LIB_ENTRY::name, ORCAD_SYMBOL_DEF::name, ORCAD_ST_GLOBAL_SYMBOL, ORCAD_CONVERTER::UNIT_INFO::pinNumbers, ORCAD_CONVERTER::LIB_ENTRY::powerNet, ORCAD_CONVERTER::LIB_ENTRY::refPrefix, ORCAD_CONVERTER::UNIT_INFO::symbol, SymbolId(), ORCAD_SYMBOL_DEF::typeId, and ORCAD_CONVERTER::LIB_ENTRY::units.

Referenced by placePowerSymbol().

◆ powerNet()

std::string ORCAD_CONVERTER::powerNet ( const ORCAD_RAW_PAGE & aPage,
const ORCAD_GRAPHIC_INST & aInst ) const
private

Net stamped by a power-symbol instance: the net of the wire its pin touches (authoritative — ports can be renamed), falling back to the symbol name.

Trimmed of surrounding whitespace.

Definition at line 1083 of file orcad_converter_sheet.cpp.

References graphicPinPos(), ORCAD_GRAPHIC_INST::logicalName, ORCAD_GRAPHIC_INST::name, netAt(), pin, and ORCAD_GRAPHIC_INST::props.

Referenced by convertPage().

◆ prepareSymbols()

void ORCAD_CONVERTER::prepareSymbols ( )
private

Pre-pass over all pages: synthesize placeholder definitions for symbols absent from the cache (one note per name), register a LIB_ENTRY + unit for every placed instance via libForInstance(), then computeFontBaseline().

Definition at line 179 of file orcad_converter_symbols.cpp.

References _, computeFontBaseline(), FromOrcadString(), ORCAD_RAW_PAGE::instances, libForInstance(), m_design, name, note(), ORCAD_PLACED_INSTANCE::pkgName, and synthesizeSymbol().

Referenced by Convert().

◆ resolveReference()

wxString ORCAD_CONVERTER::resolveReference ( const ORCAD_PLACED_INSTANCE & aInst) const
private

Resolve a placed instance's reference designator, falling back to the Hierarchy-stream occurrence designator when the instance carries only the unannotated "C?" template; returns "?" when neither is annotated.

Definition at line 1307 of file orcad_converter_symbols.cpp.

References ORCAD_PLACED_INSTANCE::dbId, FromOrcadString(), m_currentOccRefs, and ORCAD_PLACED_INSTANCE::reference.

Referenced by placeInstance().

◆ SanitizeFileName()

wxString ORCAD_CONVERTER::SanitizeFileName ( const std::string & aName)
staticprivate

Filesystem-safe name: control characters and <>:"/|?

  • replaced by '_', surrounding spaces/dots stripped, "unnamed" when empty.

Definition at line 583 of file orcad_converter_sheet.cpp.

References FromOrcadString().

Referenced by MakePageFileName().

◆ snapToWire()

VECTOR2I ORCAD_CONVERTER::snapToWire ( int aX,
int aY,
const ORCAD_WIRE & aWire )
staticprivate

Closest point (DBU) on a wire segment to (aX, aY); exact for H/V wires.

Definition at line 1708 of file orcad_converter_sheet.cpp.

References KiROUND(), ORCAD_WIRE::x1, ORCAD_WIRE::x2, ORCAD_WIRE::y1, and ORCAD_WIRE::y2.

Referenced by placeWires().

◆ SymbolId()

std::string ORCAD_CONVERTER::SymbolId ( const std::string & aName)
staticprivate

LIB_ID-safe symbol name: ':', '"', '/' and whitespace runs -> '_'; "SYM" if empty.

Definition at line 1708 of file orcad_converter_symbols.cpp.

Referenced by BuildSymbolLibrary(), libForInstance(), and powerLibFor().

◆ synthesizeSymbol()

ORCAD_SYMBOL_DEF ORCAD_CONVERTER::synthesizeSymbol ( const std::string & aPkgName,
const std::vector< const ORCAD_PLACED_INSTANCE * > & aInstances ) const
private

Best-effort placeholder for a cache-less symbol, built from the instances' T0x10 absolute pin records and the placed bbox: rectangle body with pins on the sides where they actually sit.

Uses the instance closest to the reference orientation (code 0 preferred); local pin p solves T = I + t(w, h) + M*p, and the t-term cancels for instances sharing the reference orientation, so connectivity is exact there. With no pin records the body comes from the inverse-transformed placed bbox. Sets synthesized = true.

Definition at line 329 of file orcad_converter_symbols.cpp.

References ORCAD_ORIENT_ENTRY::a, ORCAD_ORIENT_ENTRY::b, ORCAD_PLACED_INSTANCE::bbox, ORCAD_SYMBOL_DEF::bbox, ORCAD_ORIENT_ENTRY::c, ORCAD_ORIENT_ENTRY::d, ORCAD_PRIMITIVE::kind, ORCAD_PLACED_INSTANCE::mirror, ORCAD_SYMBOL_DEF::name, ORCAD_ORIENT_TABLE, ORCAD_ST_LIBRARY_PART, OrcadOrientOf(), OrcadOrientOffset(), PASSIVE, pin, PIN_LEN_DBU, ORCAD_PLACED_INSTANCE::pins, ORCAD_SYMBOL_DEF::pins, ORCAD_SYMBOL_DEF::primitives, RECT, ORCAD_PLACED_INSTANCE::rotation, ORCAD_SYMBOL_DEF::synthesized, ORCAD_SYMBOL_DEF::typeId, ORCAD_PIN_INST::x, ORCAD_PLACED_INSTANCE::x, ORCAD_POINT::x, ORCAD_BBOX::x1, ORCAD_PRIMITIVE::x1, ORCAD_BBOX::x2, ORCAD_PRIMITIVE::x2, ORCAD_PIN_INST::y, ORCAD_PLACED_INSTANCE::y, ORCAD_POINT::y, ORCAD_BBOX::y1, ORCAD_PRIMITIVE::y1, ORCAD_BBOX::y2, and ORCAD_PRIMITIVE::y2.

Referenced by prepareSymbols().

◆ textSizeIU()

int ORCAD_CONVERTER::textSizeIU ( int aFontIdx) const
private

Text size in IU for a font reference: 1.27 mm when the height is unknown; with a baseline, 1.27 mm * height / baseline clamped to [0.7, 5.0] mm; without a baseline, height * 25.4 * 0.75 / 96 mm with a 0.7 mm floor.

Definition at line 1667 of file orcad_converter_symbols.cpp.

References fontHeightDbu(), and m_fontBaselineDbu.

Referenced by addSymbolPrimitive(), placeGraphics(), placeSymbolFields(), and placeWires().

◆ toKicadOrientation()

int ORCAD_CONVERTER::toKicadOrientation ( int aOrient)
staticprivate

Map an orientation code to the composed SYMBOL_ORIENTATION_T value for SCH_SYMBOL::SetOrientation(): 0 -> SYM_ORIENT_0 4 -> SYM_ORIENT_0 + SYM_MIRROR_Y 1 -> SYM_ORIENT_90 5 -> SYM_ORIENT_90 + SYM_MIRROR_X 2 -> SYM_ORIENT_180 6 -> SYM_ORIENT_0 + SYM_MIRROR_X 3 -> SYM_ORIENT_270 7 -> SYM_ORIENT_270 + SYM_MIRROR_X.

Definition at line 1178 of file orcad_converter_symbols.cpp.

References SYM_MIRROR_X, SYM_MIRROR_Y, SYM_ORIENT_0, SYM_ORIENT_180, SYM_ORIENT_270, and SYM_ORIENT_90.

Referenced by placeInstance(), and placePowerSymbol().

◆ unitLetter()

std::string ORCAD_CONVERTER::unitLetter ( const ORCAD_PLACED_INSTANCE & aInst) const
private

Unit discriminator of an instance: the part of pkgName between the package base name and the '.View' suffix ("A", "-16", "", ...), plus ":View" when the view is not "Normal" (DeMorgan variants).

Definition at line 510 of file orcad_converter_symbols.cpp.

References ORCAD_PLACED_INSTANCE::pkgName, and ORCAD_PLACED_INSTANCE::sourcePackage.

Referenced by libForInstance().

◆ warn()

void ORCAD_CONVERTER::warn ( const wxString & aMsg)
private

Conversion problem: REPORTER at RPT_SEVERITY_WARNING.

Definition at line 182 of file orcad_converter_sheet.cpp.

References m_reporter, and RPT_SEVERITY_WARNING.

Referenced by libForInstance(), placeBitmap(), and placeInstance().

Member Data Documentation

◆ LIB_NICK

const char* ORCAD_CONVERTER::LIB_NICK = "orcad_import"
staticconstexpr

Symbol library nickname used in every emitted LIB_ID.

Definition at line 244 of file orcad_converter.h.

Referenced by kicadSymbolFor(), placeInstance(), and placePowerSymbol().

◆ m_currentOccRefs

const std::map<uint32_t, std::string>* ORCAD_CONVERTER::m_currentOccRefs = nullptr
private

Occurrence reference designators of the scope currently being converted; set per page so a child schematic reused by several block occurrences takes each occurrence's own designators.

Null when the design has no occurrence tree.

Definition at line 674 of file orcad_converter.h.

Referenced by Convert(), and resolveReference().

◆ m_design

◆ m_fontBaselineDbu

int ORCAD_CONVERTER::m_fontBaselineDbu
private

dominant text height; 0 = none

Definition at line 669 of file orcad_converter.h.

Referenced by computeFontBaseline(), ORCAD_CONVERTER(), and textSizeIU().

◆ m_libSymbols

std::map<std::string, LIB_ENTRY> ORCAD_CONVERTER::m_libSymbols
private

keyed by emitted lib name

Definition at line 666 of file orcad_converter.h.

Referenced by BuildSymbolLibrary(), kicadSymbolFor(), libForInstance(), placeInstance(), placePowerSymbol(), and powerLibFor().

◆ m_pkgToLib

std::map<PKG_KEY, std::pair<std::string, int> > ORCAD_CONVERTER::m_pkgToLib
private

Definition at line 667 of file orcad_converter.h.

Referenced by libForInstance().

◆ m_powerCount

int ORCAD_CONVERTER::m_powerCount
private

"#PWR%04d" counter

Definition at line 668 of file orcad_converter.h.

Referenced by ORCAD_CONVERTER(), and placePowerSymbol().

◆ m_progressReporter

PROGRESS_REPORTER* ORCAD_CONVERTER::m_progressReporter
private

Definition at line 663 of file orcad_converter.h.

Referenced by Convert(), and ORCAD_CONVERTER().

◆ m_reporter

REPORTER* ORCAD_CONVERTER::m_reporter
private

Definition at line 662 of file orcad_converter.h.

Referenced by note(), ORCAD_CONVERTER(), and warn().

◆ m_rootSheet

SCH_SHEET* ORCAD_CONVERTER::m_rootSheet
private

Definition at line 664 of file orcad_converter.h.

Referenced by Convert(), and ORCAD_CONVERTER().

◆ m_schematic

SCHEMATIC* ORCAD_CONVERTER::m_schematic
private

Definition at line 661 of file orcad_converter.h.

Referenced by Convert(), and ORCAD_CONVERTER().

◆ m_usedSheetNames

std::set<wxString> ORCAD_CONVERTER::m_usedSheetNames
private

Lower-cased sheet names already emitted, to keep sibling sheet names unique.

Definition at line 677 of file orcad_converter.h.

Referenced by Convert().

◆ m_wireEndpoints

std::map<std::pair<int, int>, std::vector<const ORCAD_WIRE*> > ORCAD_CONVERTER::m_wireEndpoints
private

Per-page wire lookup: endpoint -> wires ending there. Rebuilt by buildNetLookup().

Definition at line 680 of file orcad_converter.h.

Referenced by buildNetLookup(), netAt(), and placeOffpageConnectors().

◆ MARGIN_B_DBU

int ORCAD_CONVERTER::MARGIN_B_DBU = 100
staticconstexprprivate

Definition at line 292 of file orcad_converter.h.

Referenced by applyPageSettings().

◆ MARGIN_L_DBU

int ORCAD_CONVERTER::MARGIN_L_DBU = 60
staticconstexprprivate

Page content margins, DBU.

KiCad draws its frame about 10 mm inside the paper edge, so content needs clearance the OrCAD canvas did not; the bottom margin leaves extra room for KiCad's title block strip.

Definition at line 289 of file orcad_converter.h.

Referenced by applyPageSettings().

◆ MARGIN_R_DBU

int ORCAD_CONVERTER::MARGIN_R_DBU = 60
staticconstexprprivate

Definition at line 291 of file orcad_converter.h.

Referenced by applyPageSettings().

◆ MARGIN_T_DBU

int ORCAD_CONVERTER::MARGIN_T_DBU = 60
staticconstexprprivate

Definition at line 290 of file orcad_converter.h.

Referenced by applyPageSettings().

◆ PIN_LEN_DBU

int ORCAD_CONVERTER::PIN_LEN_DBU = 10
staticconstexprprivate

Standard OrCAD pin length used for synthesized placeholder pins, DBU.

Definition at line 284 of file orcad_converter.h.

Referenced by synthesizeSymbol().


The documentation for this class was generated from the following files: