46#ifndef ORCAD_CONVERTER_H_
47#define ORCAD_CONVERTER_H_
133 { 0, 0, 0, 0, 1, 0, 0, 1 },
134 { 90, 0, 0, 1, 0, 1, -1, 0 },
135 { 180, 0, 1, 2, -1, 0, 0, -1 },
136 { 270, 0, 2, 0, 0, -1, 1, 0 },
137 { 0,
'y', 1, 0, -1, 0, 0, 1 },
138 { 90,
'x', 0, 0, 0, 1, 1, 0 },
139 { 0,
'x', 0, 2, 1, 0, 0, -1 },
140 { 270,
'x', 2, 1, 0, -1, -1, 0 }
147 return ( aRotation & 3 ) | ( aMirror ? 0x4 : 0 );
153 return aSelector == 1 ? aWidth : aSelector == 2 ? aHeight : 0;
178 return VECTOR2I( aBaseX + t.
x + e.
a * aPx + e.
b * aPy,
179 aBaseY + t.
y + e.
c * aPx + e.
d * aPy );
244 static constexpr const char*
LIB_NICK =
"orcad_import";
279 using PKG_KEY = std::tuple<std::string, std::string, int>;
297 void warn(
const wxString& aMsg );
300 void note(
const wxString& aMsg );
324 const std::vector<const ORCAD_PLACED_INSTANCE*>& aInstances )
const;
363 std::string
powerLibFor(
const std::string& aSymbolName,
const std::string& aNetName );
398 int aUnit,
bool aPower,
const std::string& aNameOverride );
450 const std::string& aFootprint );
483 static std::string
SymbolId(
const std::string& aName );
502 static wxString
MakePageFileName(
int aPageIndex,
const std::string& aPageName );
645 static bool MakeBmpFromDib(
const std::vector<uint8_t>& aDib, wxMemoryBuffer& aOut );
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
A color representation with 4 components: red, green, blue, alpha.
Define a library symbol object.
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 bbo...
void placeJunctions(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
Append computed junctions as SCH_JUNCTION items.
std::vector< VECTOR2I > computeJunctions(const ORCAD_RAW_PAGE &aPage) const
Junction points (DBU) from wire geometry + shared net ids.
void prepareSymbols()
Pre-pass over all pages: synthesize placeholder definitions for symbols absent from the cache (one no...
void computeFontBaseline()
Find the design's dominant text height (most frequent font height over all alias and display-prop fon...
std::vector< OFFPAGE_NET > offpageNets(const ORCAD_RAW_PAGE &aPage) const
Resolve every off-page connector on the page to (index, net, pin position).
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 w...
static constexpr int MARGIN_B_DBU
PROGRESS_REPORTER * m_progressReporter
SCH_SHEET * Convert(SCH_SHEET *aRootSheet)
Populate the schematic.
void buildNetLookup(const ORCAD_RAW_PAGE &aPage)
Rebuild m_wireEndpoints for a page (both endpoints of every wire).
void convertPage(ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen, const SCH_SHEET_PATH &aSheetPath)
Convert one page onto a screen: applyTitleBlock(), buildNetLookup(), then junctions,...
std::pair< std::string, int > libForInstance(const ORCAD_PLACED_INSTANCE &aInst)
Resolve/register the emitted lib symbol and unit number for a placed part.
static constexpr int PIN_LEN_DBU
Standard OrCAD pin length used for synthesized placeholder pins, DBU.
static constexpr int MARGIN_R_DBU
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 transfor...
const std::map< uint32_t, std::string > * m_currentOccRefs
Occurrence reference designators of the scope currently being converted; set per page so a child sche...
VECTOR2I graphicPinPos(const ORCAD_GRAPHIC_INST &aInst) const
Absolute connection point (DBU) of a GraphicInst-derived instance (power symbol / off-page connector ...
void applyPageSettings(ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
Fit the page and set the screen's PAGE_INFO.
ORCAD_CONVERTER(ORCAD_DESIGN &aDesign, SCHEMATIC *aSchematic, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter=nullptr)
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.
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 pix...
~ORCAD_CONVERTER()
Out-of-line: LIB_ENTRY holds LIB_SYMBOL by unique_ptr. [orcad_converter_sheet.cpp].
static wxString MakePageFileName(int aPageIndex, const std::string &aPageName)
"P%02d_<pagename>.kicad_sch" (1-based index), sanitized: control characters and the characters <>:"/|...
LIB_SYMBOL * kicadSymbolFor(const std::string &aLibName)
Return the fully built KiCad LIB_SYMBOL for a registered LIB_ENTRY, building and caching it on first ...
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...
static BOX2I pageExtentDbu(const ORCAD_RAW_PAGE &aPage)
Bounding box (DBU) of everything drawable on the page: wire ends, instance placed bboxes + T0x10 pin ...
std::map< PKG_KEY, std::pair< std::string, int > > m_pkgToLib
void note(const wxString &aMsg)
Fact about the source design (not a conversion problem): RPT_SEVERITY_INFO.
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...
int m_fontBaselineDbu
dominant text height; 0 = none
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 sy...
std::set< wxString > m_usedSheetNames
Lower-cased sheet names already emitted, to keep sibling sheet names unique.
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().
int textSizeIU(int aFontIdx) const
Text size in IU for a font reference: 1.27 mm when the height is unknown; with a baseline,...
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 snap...
std::map< std::string, LIB_ENTRY > m_libSymbols
keyed by emitted lib name
void applyFont(EDA_TEXT *aText, int aFontIdx) const
static int toKicadOrientation(int aOrient)
Map an orientation code to the composed SYMBOL_ORIENTATION_T value for SCH_SYMBOL::SetOrientation(): ...
int m_powerCount
"#PWR%04d" counter
void applyTitleBlock(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
Fill the screen TITLE_BLOCK from the first page title block carrying properties: Title,...
void placeDefinitionImages(const ORCAD_SYMBOL_DEF &aDefinition, int aBaseX, int aBaseY, int aOrient, SCH_SCREEN *aScreen)
wxString resolveReference(const ORCAD_PLACED_INSTANCE &aInst) const
Resolve a placed instance's reference designator, falling back to the Hierarchy-stream occurrence des...
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,...
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 '....
static std::string SymbolId(const std::string &aName)
LIB_ID-safe symbol name: ':', '"', '/' and whitespace runs -> '_'; "SYM" if empty.
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.
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...
int fontHeightDbu(int aFontIdx) const
|lfHeight| of a 1-based font index; 0 for invalid/default indices.
void placeOffpageConnectors(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
SCH_GLOBALLABEL per resolved off-page connector, at the connection point; an unconnected connector (e...
static constexpr int MARGIN_T_DBU
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 dr...
std::string powerLibFor(const std::string &aSymbolName, const std::string &aNetName)
Resolve/register the power lib symbol for a power-symbol instance.
void warn(const wxString &aMsg)
Conversion problem: REPORTER at RPT_SEVERITY_WARNING.
void placeDefinitionVectors(const ORCAD_SYMBOL_DEF &aDefinition, int aBaseX, int aBaseY, int aOrient, SCH_SCREEN *aScreen)
void placeNoConnects(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
SCH_NO_CONNECT per ERC object, at the object's anchor.
std::vector< LIB_SYMBOL * > BuildSymbolLibrary()
Build KiCad library symbols from the design cache and packages alone (no schematic pages),...
void placePorts(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen, bool aHierarchical)
SCH_HIERLABEL per port on a hierarchical child page, otherwise SCH_GLOBALLABEL.
static constexpr const char * LIB_NICK
Symbol library nickname used in every emitted LIB_ID.
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 constexpr int MARGIN_L_DBU
Page content margins, DBU.
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 ca...
std::map< std::pair< int, int >, std::vector< const ORCAD_WIRE * > > m_wireEndpoints
Per-page wire lookup: endpoint -> wires ending there. Rebuilt by buildNetLookup().
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).
std::tuple< std::string, std::string, int > PKG_KEY
(sourcePackage-or-pkgName, pkgName, variant index) -> (lib name, unit number).
static wxString SanitizeFileName(const std::string &aName)
Filesystem-safe name: control characters and <>:"/|?
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 of...
A progress reporter interface for use in multi-threaded environments.
A pure virtual class used to derive REPORTER objects from.
Holds all the data relating to one schematic.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
constexpr ORCAD_ORIENT_ENTRY ORCAD_ORIENT_TABLE[8]
Orientation table, indexed by the 3-bit orientation code.
VECTOR2I OrcadDbuToIu(int aX, int aY)
FILL_T OrcadFillType(int aFillStyle, int aHatchStyle)
VECTOR2I OrcadTransformPoint(int aOrient, int aWidth, int aHeight, int aBaseX, int aBaseY, int aPx, int aPy)
Absolute canvas position (DBU) of symbol-space point (aPx, aPy) for an instance with transform base (...
int OrcadOrientDim(int aSelector, int aWidth, int aHeight)
int OrcadLineWidthIu(int aWidth)
int OrcadPageOrder(wxString &aName)
Return a numeric page prefix (or -1); strip only the "N - title" convention.
KIGFX::COLOR4D OrcadColor(int aColorIndex)
int OrcadOrientOf(int aRotation, bool aMirror)
Compose the 3-bit orientation code from the rotation bits and mirror bit.
constexpr int ORCAD_IU_PER_DBU
Schematic internal units per OrCAD DBU: 10 mil * 254 IU/mil.
LINE_STYLE OrcadLineStyle(int aStyle)
VECTOR2I OrcadOrientOffset(int aOrient, int aWidth, int aHeight)
Bbox re-anchoring offset for the given orientation and body size (DBU).
Plain data records produced by the OrCAD Capture DSN stream parsers and consumed by ORCAD_CONVERTER.
LINE_STYLE
Dashed line types.
One emitted KiCad lib symbol (possibly multi-unit).
std::string name
lib item name (no nickname)
std::unique_ptr< LIB_SYMBOL > kicadSymbol
built lazily by kicadSymbolFor()
std::vector< UNIT_INFO > units
sorted by letter; unit numbers are 1-based indices
std::string powerNet
power symbols are keyed by NET name
One resolved off-page connector: index into page.offpage, net, pin position.
One unit of an emitted multi-unit symbol.
const ORCAD_SYMBOL_DEF * symbol
std::vector< std::string > pinNumbers
device pin-number map for this unit
std::string letter
unit discriminator, e.g. "A", "-16", "B:Convert"
Everything parsed from one .DSN, as handed to ORCAD_CONVERTER.
Shared body of Port / Global / OffPageConnector / TitleBlock / ERCObject and the Graphic*Inst shapes ...
One entry of the 8-orientation placement table.
char mirror
0 = none, 'x' or 'y' = KiCad mirror axis
int8_t tySel
Y offset selector.
int angle
KiCad placement angle in degrees (0/90/180/270, CCW)
int8_t txSel
X offset selector.
A placed part instance on a page (structure type 13).
One graphic primitive of a symbol body or nested page graphic.
One parsed 'Views/<folder>/Pages/<page>' stream, raw structure lists in stream order.
A symbol definition from the design Cache (LibraryPart / GlobalSymbol / PortSymbol / OffPageSymbol / ...
One pin of a symbol definition (structure types 26/27).
VECTOR2< int32_t > VECTOR2I