KiCad PCB EDA Suite
Loading...
Searching...
No Matches
orcad_converter.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * Based on the dsn2kicad reference implementation and on OrCAD file format
7 * documentation from the OpenOrCadParser project (MIT licensed).
8 *
9 * This program is free software: you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the
11 * Free Software Foundation, either version 3 of the License, or (at your
12 * option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 */
22
24
25#ifndef ORCAD_CONVERTER_H_
26#define ORCAD_CONVERTER_H_
27
28#include <cstdint>
29#include <map>
30#include <memory>
31#include <set>
32#include <string>
33#include <tuple>
34#include <utility>
35#include <vector>
36
37#include <wx/string.h>
38
39#include <geometry/seg.h>
40#include <math/box2.h>
41#include <math/vector2d.h>
42#include <gal/color4d.h>
43#include <eda_shape.h>
44#include <kiid.h>
45
47
48class LIB_SYMBOL;
49class SCH_LINE;
50class EDA_TEXT;
52class REPORTER;
53class SCHEMATIC;
54class SCH_ITEM;
55class SCH_LABEL_BASE;
56class SCH_LABEL;
57class SCH_SCREEN;
58class SCH_SHEET;
59class SCH_SHEET_PIN;
60class SCH_SHEET_PATH;
61class SCH_SYMBOL;
62class SCH_TEXT;
63class wxMemoryBuffer;
64
65
67inline constexpr int ORCAD_IU_PER_DBU = 2540;
68
69KIGFX::COLOR4D OrcadColor( int aColorIndex );
70int OrcadLineWidthIu( int aWidth );
71int OrcadPageGraphicLineWidthIu( int aWidth );
72LINE_STYLE OrcadLineStyle( int aStyle );
73std::pair<double, double> OrcadDashRatios( int aFormatVersionMajor );
74FILL_T OrcadFillType( int aFillStyle, int aHatchStyle );
75int OrcadHatchPitchIu( uint32_t aModifyTimestamp );
76int OrcadHatchLineWidthIu( uint32_t aModifyTimestamp );
77std::vector<SEG> OrcadHatchLines( const EDA_SHAPE& aShape, int aHatchStyle, int aPitch );
78int OrcadTextBaselineOffset( int aTextSize );
79int OrcadDisplayType( const ORCAD_DISPLAY_PROP& aProp );
83int OrcadDisplayFontId( const ORCAD_DISPLAY_PROP& aProp );
84int OrcadPageOrder( wxString& aName );
85VECTOR2I OrcadStretchedImageSize( int aWidth, int aHeight, int aBoxWidth, int aBoxHeight );
86wxString OrcadPinNameMarkup( const wxString& aName );
87
88inline VECTOR2I OrcadDbuToIu( int aX, int aY )
89{
90 return VECTOR2I( aX * ORCAD_IU_PER_DBU, aY * ORCAD_IU_PER_DBU );
91}
92
93
97{
98 int angle;
99 char mirror;
100 int8_t txSel;
101 int8_t tySel;
102 int8_t a;
103 int8_t b;
104 int8_t c;
105 int8_t d;
106};
107
108
111 { 0, 0, 0, 0, 1, 0, 0, 1 }, { 90, 0, 0, 1, 0, 1, -1, 0 }, { 180, 0, 1, 2, -1, 0, 0, -1 },
112 { 270, 0, 2, 0, 0, -1, 1, 0 }, { 0, 'y', 1, 0, -1, 0, 0, 1 }, { 90, 'x', 0, 0, 0, 1, 1, 0 },
113 { 0, 'x', 0, 2, 1, 0, 0, -1 }, { 270, 'x', 2, 1, 0, -1, -1, 0 }
114};
115
116
118inline int OrcadOrientOf( int aRotation, bool aMirror )
119{
120 return ( aRotation & 3 ) | ( aMirror ? 0x4 : 0 );
121}
122
123
124inline int OrcadOrientDim( int aSelector, int aWidth, int aHeight )
125{
126 return aSelector == 1 ? aWidth : aSelector == 2 ? aHeight : 0;
127}
128
129
131inline VECTOR2I OrcadOrientOffset( int aOrient, int aWidth, int aHeight )
132{
133 const ORCAD_ORIENT_ENTRY& e = ORCAD_ORIENT_TABLE[aOrient & 7];
134 return VECTOR2I( OrcadOrientDim( e.txSel, aWidth, aHeight ), OrcadOrientDim( e.tySel, aWidth, aHeight ) );
135}
136
137
139inline VECTOR2I OrcadTransformPoint( int aOrient, int aWidth, int aHeight, int aBaseX, int aBaseY, int aPx, int aPy )
140{
141 const ORCAD_ORIENT_ENTRY& e = ORCAD_ORIENT_TABLE[aOrient & 7];
142 VECTOR2I t = OrcadOrientOffset( aOrient, aWidth, aHeight );
143
144 return VECTOR2I( aBaseX + t.x + e.a * aPx + e.b * aPy, aBaseY + t.y + e.c * aPx + e.d * aPy );
145}
146
147
149{
150public:
152 ORCAD_CONVERTER( ORCAD_DESIGN& aDesign, SCHEMATIC* aSchematic, REPORTER* aReporter,
153 PROGRESS_REPORTER* aProgressReporter = nullptr );
154
157
159 SCH_SHEET* Convert( SCH_SHEET* aRootSheet );
160
162 std::vector<LIB_SYMBOL*> BuildSymbolLibrary();
163
165 static constexpr const char* LIB_NICK = "orcad_import";
166
167private:
169
172 {
173 std::string letter;
174 const ORCAD_SYMBOL_DEF* symbol = nullptr;
175 std::vector<std::string> pinNumbers;
176 std::vector<bool> pinNumberVisible;
177 std::vector<bool> pinIgnore;
178 std::vector<int> pinOffsets;
179 std::vector<bool> explicitPinNets;
180
181 bool operator==( const UNIT_INFO& ) const = default;
182 };
183
186 {
187 std::string name;
188 std::vector<UNIT_INFO> units;
189 bool isPower = false;
190 std::string powerNet;
191 std::string refPrefix = "U";
192 std::string footprint;
193 std::unique_ptr<LIB_SYMBOL> kicadSymbol;
194 };
195
198 {
199 int index = 0;
200 std::string net;
201 int x = 0;
202 int y = 0;
203 };
204
207 using PKG_KEY = std::tuple<std::string, std::string, int, std::string>;
208
217
219
221 static constexpr int PIN_LEN_DBU = 10;
222
224 static constexpr int MARGIN_L_DBU = 60;
225 static constexpr int MARGIN_T_DBU = 60;
226 static constexpr int MARGIN_R_DBU = 60;
227 static constexpr int MARGIN_B_DBU = 100;
228
230
232 void warn( const wxString& aMsg );
233
235 void note( const wxString& aMsg );
236
239
241 std::string canonicalGlobalNetName( const std::string& aName ) const;
242 std::string effectiveInterfaceNetName( const std::string& aName ) const;
243 std::string occurrenceElectricalNetName( uint32_t aOccurrenceId, const std::string& aName ) const;
244 bool isPowerNetName( const std::string& aName ) const;
245 bool isOffpageNetName( const std::string& aName ) const;
246
247
248 void prepareSymbols();
249
251 ORCAD_SYMBOL_DEF synthesizeSymbol( const std::string& aPkgName,
252 const std::vector<const ORCAD_PLACED_INSTANCE*>& aInstances ) const;
253
255 std::string unitLetter( const ORCAD_PLACED_INSTANCE& aInst ) const;
256
258 std::pair<const ORCAD_SYMBOL_DEF*, int> pickVariant( const ORCAD_PLACED_INSTANCE& aInst ) const;
259
261 std::pair<std::string, int> libForInstance( const ORCAD_PLACED_INSTANCE& aInst,
262 const PKG_KEY** aSourceUnit = nullptr );
264
266 std::optional<uint32_t> occurrenceNetIdFor( const std::string* aName ) const;
267
269 void finishConversion();
270
272 std::string powerLibFor( const std::string& aSymbolName, const std::string& aNetName );
273
274
275 LIB_SYMBOL* kicadSymbolFor( const std::string& aLibName );
276
277
278 void addSymbolPrimitive( LIB_SYMBOL* aSymbol, const ORCAD_PRIMITIVE& aPrim, int aUnit, int aColor,
279 int aOffsetX = 0, int aOffsetY = 0 );
280
282 void addSymbolArc( LIB_SYMBOL* aSymbol, const ORCAD_PRIMITIVE& aPrim, int aUnit, int aColor, int aOffsetX = 0,
283 int aOffsetY = 0 );
284
285
286 void addSymbolPin( LIB_SYMBOL* aSymbol, const ORCAD_SYMBOL_PIN& aPin, const wxString& aNumber, int aUnit,
287 bool aPower, const std::string& aNameOverride, bool aNameVisible, bool aShowPinNumbers,
288 bool aNumberVisible, const BOX2I* aBodyBox, bool aHidden = false,
289 bool aExplicitNet = false );
290
291
292 void placeInstance( ORCAD_RAW_PAGE& aPage, const ORCAD_PLACED_INSTANCE& aInst, SCH_SCREEN* aScreen,
293 const SCH_SHEET_PATH& aSheetPath );
294
296 wxString resolveReference( const ORCAD_PLACED_INSTANCE& aInst ) const;
297
298
299 void placePowerSymbol( ORCAD_RAW_PAGE& aPage, const ORCAD_GRAPHIC_INST& aInst, const std::string& aNet,
300 SCH_SCREEN* aScreen, const SCH_SHEET_PATH& aSheetPath );
301
302
303 void placeSymbolFields( SCH_SYMBOL* aSymbol, const ORCAD_PLACED_INSTANCE& aInst, const ORCAD_SYMBOL_DEF& aDef,
304 int aOrient, const std::string& aValue, const std::string& aFootprint );
305
307 const ORCAD_PACKAGE* packageFor( const ORCAD_PLACED_INSTANCE& aInst ) const;
308
310 std::map<std::string, std::string> effectiveProps( const ORCAD_PLACED_INSTANCE& aInst,
311 const ORCAD_SYMBOL_DEF& aDef ) const;
312
313
314 static int toKicadOrientation( int aOrient );
315
316 void computeFontBaseline();
317
318 int displayFontId( const ORCAD_DISPLAY_PROP& aProp ) const;
319 bool displayUsesTemplateFont( const ORCAD_DISPLAY_PROP& aProp ) const;
320 int wireAliasFontId( const ORCAD_ALIAS& aAlias ) const;
321 int textBaselineOffset( int aTextSize, int aFontIdx, bool aTemplateFont = true ) const;
322
324 int resolveFontIndex( int aFontIdx ) const;
325
327 int fontHeightDbu( int aFontIdx, bool aTemplateFont = true ) const;
328
329
330 int textSizeIU( int aFontIdx, bool aTemplateFont = true ) const;
331
333 VECTOR2I textSize( int aFontIdx, bool aTemplateFont = true ) const;
334
335 void applyFont( EDA_TEXT* aText, int aFontIdx, bool aTemplateFont = true ) const;
336 void applyMultilineSpacing( SCH_TEXT* aText, int aFontIdx, bool aTemplateFont = true ) const;
337
339 static std::string SymbolId( const std::string& aName );
340
341
342 void convertPage( ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen, const SCH_SHEET_PATH& aSheetPath,
343 bool aContainerPage = false, bool aSharedFolderPage = false );
345 const std::string& aChildFolder );
347 void appendNetIntent( SCH_SCREEN* aScreen, SCH_LABEL* aLabel, bool aExplicitName, uint32_t aNetId = 0 );
348 void minimizeNetLabels();
349 void finalizeNetNames();
350 void recordNetNameMap();
352
353 KIID deterministicUuid( const std::string& aRole, size_t aOrdinal ) const;
354 void appendPageItem( SCH_SCREEN* aScreen, SCH_ITEM* aItem );
355 void assignPageItemUuids( size_t aPageOrdinal );
356
357
358 static wxString MakePageFileName( int aPageIndex, const std::string& aPageName );
359
361 void applyPageSettings( ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen );
362 void placePageFrame( const ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen );
363
365 static BOX2I pageExtentDbu( const ORCAD_RAW_PAGE& aPage );
366
368 static void offsetPage( ORCAD_RAW_PAGE& aPage, int aDx, int aDy );
369
370
371 void applyTitleBlock( const ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen );
372
374 void buildNetLookup( const ORCAD_RAW_PAGE& aPage );
375
377 std::string netAt( const ORCAD_RAW_PAGE& aPage, int aX, int aY ) const;
378
379
380 std::string powerNet( const ORCAD_RAW_PAGE& aPage, const ORCAD_GRAPHIC_INST& aInst ) const;
381
383 VECTOR2I graphicPinPos( const ORCAD_GRAPHIC_INST& aInst ) const;
384
386 VECTOR2I namedGraphicPinPos( const ORCAD_RAW_PAGE& aPage, const ORCAD_GRAPHIC_INST& aInst ) const;
387
389 VECTOR2I powerPinPos( const ORCAD_RAW_PAGE& aPage, const ORCAD_GRAPHIC_INST& aInst ) const;
390
391 std::vector<int> placedStackedPinOffsets( const ORCAD_PLACED_INSTANCE& aInstance ) const;
392 VECTOR2I placedPinElectricalPosition( const ORCAD_PLACED_INSTANCE& aInstance, size_t aPinIndex ) const;
393 bool hasImplicitPowerPinName( const ORCAD_PLACED_INSTANCE& aInstance, size_t aPinIndex,
394 const std::string& aNetName ) const;
395
397 std::vector<OFFPAGE_NET> offpageNets( const ORCAD_RAW_PAGE& aPage ) const;
398
400 std::vector<VECTOR2I> computeJunctions( const ORCAD_RAW_PAGE& aPage ) const;
401
403 void placeJunctions( const ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen );
404
405
406 void placeWires( const ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen, bool aHierarchical,
407 bool aNestedHierarchy, bool aSharedFolderPage );
408
410 void placeBusEntries( const ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen );
411
413 void placeGraphicDisplayText( const ORCAD_GRAPHIC_INST& aGraphic, const ORCAD_DISPLAY_PROP& aDisplay,
414 const std::string& aText, SCH_SCREEN* aScreen );
415
417 void placeOffpageConnectors( const ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen,
418 const SCH_SHEET_PATH& aSheetPath, bool aHierarchical );
419
420
421 void placePorts( const ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen, bool aHierarchical );
422
423
424 void placeGraphics( const ORCAD_RAW_PAGE& aPage, SCH_SCREEN* aScreen );
425
427 void placeBitmap( const ORCAD_PRIMITIVE& aPrim, SCH_SCREEN* aScreen, int aOrient = 0,
428 bool* aUsedEmbeddedEmf = nullptr );
429
430 void placeDefinitionImages( const ORCAD_SYMBOL_DEF& aDefinition, int aBaseX, int aBaseY, int aOrient,
431 SCH_SCREEN* aScreen );
432
433 void placeDefinitionVectors( const ORCAD_SYMBOL_DEF& aDefinition, int aBaseX, int aBaseY, int aOrient,
434 SCH_SCREEN* aScreen, double aTextScaleX = 1.0, double aTextScaleY = 1.0,
435 bool aUseGenericTextBaseline = false,
436 const std::string& aTextFaceOverride = {} );
437
439 static VECTOR2I snapToWire( int aX, int aY, const ORCAD_WIRE& aWire );
440
442 static bool onSegment( int aX, int aY, const ORCAD_WIRE& aWire );
443
444
445 static wxString SanitizeFileName( const std::string& aName );
446
447private:
453
454 std::map<std::string, LIB_ENTRY> m_libSymbols;
455 std::map<PKG_KEY, std::pair<std::string, int>> m_pkgToLib;
456 std::map<PKG_KEY, std::pair<std::string, int>> m_preparedPkgToLib;
457 std::map<std::string, std::vector<UNIT_INFO>> m_preparedLibUnits;
458 std::vector<PLACED_PACKAGE_UNIT> m_placedPackageUnits;
459 std::set<std::string> m_nativePowerFamilies;
460 std::map<std::string, std::string> m_globalNetNames;
461 std::map<std::string, std::string> m_globalNetAliases;
462 std::set<std::string> m_powerNetNames;
463 std::set<std::string> m_offpageNetNames;
464 std::set<std::string> m_connectedBlockInterfaceNames;
465 std::map<std::string, size_t> m_occurrenceNetNameScopeCounts;
466 std::map<std::string, size_t> m_occurrenceNetNameMinDepth;
469 size_t m_pageOrdinal = 0;
470 size_t m_screenOrdinal = 1;
472 std::vector<SCH_ITEM*> m_pageItems;
473
475 const std::map<uint32_t, std::string>* m_currentOccRefs = nullptr;
476 const std::map<uint32_t, std::string>* m_currentOccUnitRefs = nullptr;
477 const std::map<uint32_t, std::map<std::string, std::string>>* m_currentOccProps = nullptr;
478 const std::map<uint32_t, std::string>* m_currentOccNetNames = nullptr;
482 std::map<std::string, std::string> m_currentUnconnectedInterfaceNetNames;
483 std::map<std::string, std::string> m_currentInterfaceNetAliases;
484 std::map<std::string, std::string> m_currentOccurrenceNetAliases;
486 std::set<const ORCAD_PIN_INST*> m_currentImplicitPowerPins;
487 std::map<std::string, std::map<std::string, std::string>> m_hierBusNamesByScreen;
488
495
497 {
500 std::vector<SCH_LINE*> wires;
501 };
502
504 const std::vector<SEG>& aSourceWires );
505
506 std::vector<INTERFACE_LABEL_SOURCE> m_interfaceLabelSources;
507 std::vector<NET_LABEL_INTENT> m_netLabelIntents;
508 std::map<SCH_LABEL_BASE*, std::pair<SCH_SCREEN*, uint32_t>> m_labelSourceNets;
509 std::map<SCH_SCREEN*, const ORCAD_RAW_PAGE*> m_sourcePages;
510 std::map<std::pair<SCH_SCREEN*, uint32_t>, std::vector<SCH_ITEM*>> m_sourceNetItems;
511 std::map<std::pair<SCH_SCREEN*, uint32_t>, std::set<std::string>> m_sourceNetNames;
512 std::map<std::pair<SCH_SCREEN*, uint32_t>, std::string> m_sourceGeneratedNetNames;
514 {
515 wxString number;
517 std::optional<KIID> libraryPin;
518 bool ignored = false;
519 };
520
521 std::map<SCH_SYMBOL*, std::vector<SOURCE_PIN_IDENTITY>> m_sourcePinIdentities;
522 std::map<SCH_SYMBOL*, const ORCAD_PLACED_INSTANCE*> m_sourceInstances;
523 std::map<SCH_SCREEN*, std::vector<wxString>> m_sourceOccurrences;
524 std::map<std::tuple<SCH_SCREEN*, const ORCAD_PLACED_INSTANCE*, size_t>, std::pair<uint32_t, std::string>> m_wirelessNetNames;
525
527 std::set<wxString> m_usedSheetNames;
528
530 std::map<std::pair<int, int>, std::vector<const ORCAD_WIRE*>> m_wireEndpoints;
531};
532
533#endif // ORCAD_CONVERTER_H_
BOX2< VECTOR2I > BOX2I
Definition box2.h:927
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
Definition kiid.h:46
Define a library symbol object.
Definition lib_symbol.h:119
void placePowerSymbol(ORCAD_RAW_PAGE &aPage, const ORCAD_GRAPHIC_INST &aInst, const std::string &aNet, SCH_SCREEN *aScreen, const SCH_SHEET_PATH &aSheetPath)
void placePageFrame(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
void placeJunctions(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
Append computed junctions as SCH_JUNCTION items.
bool displayUsesTemplateFont(const ORCAD_DISPLAY_PROP &aProp) const
std::map< std::string, std::string > m_currentInterfaceNetAliases
std::vector< VECTOR2I > computeJunctions(const ORCAD_RAW_PAGE &aPage) const
Use both geometry and net IDs; a crossing alone does not create a junction.
int displayFontId(const ORCAD_DISPLAY_PROP &aProp) const
std::vector< OFFPAGE_NET > offpageNets(const ORCAD_RAW_PAGE &aPage) const
Resolve every off-page connector on the page to (index, net, pin position).
const std::map< uint32_t, std::string > * m_currentOccUnitRefs
std::string netAt(const ORCAD_RAW_PAGE &aPage, int aX, int aY) const
Prefer endpoint nets, then intersecting wires, then endpoint aliases.
static constexpr int MARGIN_B_DBU
PROGRESS_REPORTER * m_progressReporter
SCH_SHEET * Convert(SCH_SHEET *aRootSheet)
aRootSheet must have a screen and be registered on the schematic.
void assignPageItemUuids(size_t aPageOrdinal)
void buildNetLookup(const ORCAD_RAW_PAGE &aPage)
Rebuild m_wireEndpoints for a page (both endpoints of every wire).
std::map< SCH_LABEL_BASE *, std::pair< SCH_SCREEN *, uint32_t > > m_labelSourceNets
std::map< SCH_SYMBOL *, std::vector< SOURCE_PIN_IDENTITY > > m_sourcePinIdentities
std::set< const ORCAD_PIN_INST * > m_currentImplicitPowerPins
std::vector< int > placedStackedPinOffsets(const ORCAD_PLACED_INSTANCE &aInstance) const
void rememberInterfaceLabelSource(SCH_SCREEN *aScreen, SCH_LABEL_BASE *aLabel, const std::vector< SEG > &aSourceWires)
static constexpr int PIN_LEN_DBU
– constants (calibrated; do not change) -------------------------------------—
static constexpr int MARGIN_R_DBU
std::map< SCH_SCREEN *, std::vector< wxString > > m_sourceOccurrences
std::pair< const ORCAD_SYMBOL_DEF *, int > pickVariant(const ORCAD_PLACED_INSTANCE &aInst) const
Match cached variants to placed pin positions; use the first entry if none matches.
std::map< SCH_SCREEN *, const ORCAD_RAW_PAGE * > m_sourcePages
std::set< std::string > m_currentConnectorInterfaceNetAliases
std::map< SCH_SYMBOL *, const ORCAD_PLACED_INSTANCE * > m_sourceInstances
void placeDefinitionVectors(const ORCAD_SYMBOL_DEF &aDefinition, int aBaseX, int aBaseY, int aOrient, SCH_SCREEN *aScreen, double aTextScaleX=1.0, double aTextScaleY=1.0, bool aUseGenericTextBaseline=false, const std::string &aTextFaceOverride={})
const std::map< uint32_t, std::string > * m_currentOccRefs
Per-page occurrence references distinguish repeated child schematics.
bool isOffpageNetName(const std::string &aName) const
void placeBitmap(const ORCAD_PRIMITIVE &aPrim, SCH_SCREEN *aScreen, int aOrient=0, bool *aUsedEmbeddedEmf=nullptr)
Skip undecodable images with a warning.
VECTOR2I graphicPinPos(const ORCAD_GRAPHIC_INST &aInst) const
Use the transformed cache pin position, or the instance anchor if no pin is available.
const ORCAD_PACKAGE * packageFor(const ORCAD_PLACED_INSTANCE &aInst) const
The cache package backing a placement, or nullptr when the design has none.
std::map< std::string, std::vector< UNIT_INFO > > m_preparedLibUnits
void applyPageSettings(ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
Shift content on the 10-DBU grid to preserve connectivity.
const std::map< uint32_t, std::map< std::string, std::string > > * m_currentOccProps
std::map< std::string, std::string > m_currentOccurrenceNetAliases
ORCAD_CONVERTER(ORCAD_DESIGN &aDesign, SCHEMATIC *aSchematic, REPORTER *aReporter, PROGRESS_REPORTER *aProgressReporter=nullptr)
aDesign is mutated and must outlive the converter.
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.
std::map< std::tuple< SCH_SCREEN *, const ORCAD_PLACED_INSTANCE *, size_t >, std::pair< uint32_t, std::string > > m_wirelessNetNames
~ORCAD_CONVERTER()
Out-of-line: LIB_ENTRY holds LIB_SYMBOL by unique_ptr.
void placeGraphicDisplayText(const ORCAD_GRAPHIC_INST &aGraphic, const ORCAD_DISPLAY_PROP &aDisplay, const std::string &aText, SCH_SCREEN *aScreen)
One displayed property attached to a placed page symbol, preserving source text geometry.
int resolveFontIndex(int aFontIdx) const
Resolve a Design Template font ID to its 1-based LOGFONT index.
SCH_SHEET * m_rootSheet
void addSymbolPin(LIB_SYMBOL *aSymbol, const ORCAD_SYMBOL_PIN &aPin, const wxString &aNumber, int aUnit, bool aPower, const std::string &aNameOverride, bool aNameVisible, bool aShowPinNumbers, bool aNumberVisible, const BOX2I *aBodyBox, bool aHidden=false, bool aExplicitNet=false)
VECTOR2I namedGraphicPinPos(const ORCAD_RAW_PAGE &aPage, const ORCAD_GRAPHIC_INST &aInst) const
Graphic-symbol connection point, corrected to a nearby endpoint of its named wire.
static wxString MakePageFileName(int aPageIndex, const std::string &aPageName)
LIB_SYMBOL * kicadSymbolFor(const std::string &aLibName)
static BOX2I pageExtentDbu(const ORCAD_RAW_PAGE &aPage)
Free graphics use nested primitive bounds; their outer boxes do not describe page coordinates.
std::map< PKG_KEY, std::pair< std::string, int > > m_pkgToLib
void appendPageItem(SCH_SCREEN *aScreen, SCH_ITEM *aItem)
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)
ORCAD_DESIGN & m_design
std::vector< NET_LABEL_INTENT > m_netLabelIntents
int textBaselineOffset(int aTextSize, int aFontIdx, bool aTemplateFont=true) const
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)
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.
std::vector< INTERFACE_LABEL_SOURCE > m_interfaceLabelSources
SCH_SCREEN * m_pageItemScreen
void prepareGlobalNetNames()
Capture net names ignore case; KiCad net names do not.
std::map< std::string, LIB_ENTRY > m_libSymbols
keyed by emitted lib name
std::map< std::string, size_t > m_occurrenceNetNameScopeCounts
static int toKicadOrientation(int aOrient)
int m_powerCount
"#PWR%04d" counter
void convertPage(ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen, const SCH_SHEET_PATH &aSheetPath, bool aContainerPage=false, bool aSharedFolderPage=false)
VECTOR2I powerPinPos(const ORCAD_RAW_PAGE &aPage, const ORCAD_GRAPHIC_INST &aInst) const
Power-symbol connection point, corrected to a nearby endpoint of its named wire.
KIID deterministicUuid(const std::string &aRole, size_t aOrdinal) const
std::set< std::string > m_offpageNetNames
void applyTitleBlock(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
void finishConversion()
Run the shared finalization sequence that ends every conversion entry point.
std::map< std::pair< SCH_SCREEN *, uint32_t >, std::vector< SCH_ITEM * > > m_sourceNetItems
void placeDefinitionImages(const ORCAD_SYMBOL_DEF &aDefinition, int aBaseX, int aBaseY, int aOrient, SCH_SCREEN *aScreen)
wxString resolveReference(const ORCAD_PLACED_INSTANCE &aInst) const
Use the occurrence reference when the instance has an unannotated template.
std::string occurrenceElectricalNetName(uint32_t aOccurrenceId, const std::string &aName) const
std::map< std::pair< SCH_SCREEN *, uint32_t >, std::string > m_sourceGeneratedNetNames
void applyFont(EDA_TEXT *aText, int aFontIdx, bool aTemplateFont=true) const
std::map< std::pair< SCH_SCREEN *, uint32_t >, std::set< std::string > > m_sourceNetNames
std::pair< std::string, int > libForInstance(const ORCAD_PLACED_INSTANCE &aInst, const PKG_KEY **aSourceUnit=nullptr)
Returns the registered library name and unit number.
static void offsetPage(ORCAD_RAW_PAGE &aPage, int aDx, int aDy)
aDx and aDy must be multiples of the 10-DBU grid.
VECTOR2I textSize(int aFontIdx, bool aTemplateFont=true) const
Preserve an explicit LOGFONT width while retaining natural font aspect when it is zero.
std::string unitLetter(const ORCAD_PLACED_INSTANCE &aInst) const
The unit key includes a non-Normal view so DeMorgan graphics remain distinct.
static std::string SymbolId(const std::string &aName)
LIB_ID-safe symbol name: ':', '"', '/' and whitespace runs -> '_'; "SYM" if empty.
bool isPowerNetName(const std::string &aName) const
bool hasImplicitPowerPinName(const ORCAD_PLACED_INSTANCE &aInstance, size_t aPinIndex, const std::string &aNetName) const
std::map< PKG_KEY, std::pair< std::string, int > > m_preparedPkgToLib
std::string m_currentFlatNetSuffix
void addSymbolPrimitive(LIB_SYMBOL *aSymbol, const ORCAD_PRIMITIVE &aPrim, int aUnit, int aColor, int aOffsetX=0, int aOffsetY=0)
std::vector< PLACED_PACKAGE_UNIT > m_placedPackageUnits
ORCAD_SYMBOL_DEF synthesizeSymbol(const std::string &aPkgName, const std::vector< const ORCAD_PLACED_INSTANCE * > &aInstances) const
Use placed pin positions to keep uncached symbols connected.
std::tuple< std::string, std::string, int, std::string > PKG_KEY
(sourcePackage-or-pkgName, pkgName, variant index, unit discriminator) -> (lib name,...
static constexpr int MARGIN_T_DBU
void placeHierarchicalBlockFields(SCH_SHEET *aSheet, const ORCAD_DRAWN_INSTANCE &aBlock, const std::string &aChildFolder)
SCHEMATIC * m_schematic
void placeGraphics(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen)
const std::map< uint32_t, std::string > * m_currentOccNetNames
std::string powerLibFor(const std::string &aSymbolName, const std::string &aNetName)
Key power symbols by net name because users can rename their ports.
void placeHierarchicalBlockPinFill(SCH_SCREEN *aScreen, SCH_SHEET_PIN *aPin)
std::vector< SCH_ITEM * > m_pageItems
void placeWires(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen, bool aHierarchical, bool aNestedHierarchy, bool aSharedFolderPage)
int textSizeIU(int aFontIdx, bool aTemplateFont=true) const
std::map< std::string, std::map< std::string, std::string > > m_hierBusNamesByScreen
void warn(const wxString &aMsg)
– reporting [orcad_converter_sheet.cpp] ---------------------------------------—
std::map< std::string, std::string > m_globalNetAliases
std::map< std::string, std::string > m_currentUnconnectedInterfaceNetNames
std::string canonicalGlobalNetName(const std::string &aName) const
Return the design-wide spelling selected by prepareGlobalNetNames().
REPORTER * m_reporter
void applyMultilineSpacing(SCH_TEXT *aText, int aFontIdx, bool aTemplateFont=true) const
std::map< std::string, size_t > m_occurrenceNetNameMinDepth
std::vector< LIB_SYMBOL * > BuildSymbolLibrary()
The caller owns the returned library symbols.
void placePorts(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen, bool aHierarchical)
static constexpr const char * LIB_NICK
Symbol library nickname used in every emitted LIB_ID.
int wireAliasFontId(const ORCAD_ALIAS &aAlias) const
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 margins in DBU leave room for the KiCad frame and title block.
std::set< std::string > m_connectedBlockInterfaceNames
VECTOR2I placedPinElectricalPosition(const ORCAD_PLACED_INSTANCE &aInstance, size_t aPinIndex) const
std::string powerNet(const ORCAD_RAW_PAGE &aPage, const ORCAD_GRAPHIC_INST &aInst) const
std::map< std::pair< int, int >, std::vector< const ORCAD_WIRE * > > m_wireEndpoints
Per-page wire lookup: endpoint -> wires ending there.
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::set< std::string > m_nativePowerFamilies
std::optional< uint32_t > occurrenceNetIdFor(const std::string *aName) const
Return the occurrence net id owning aName, which the table identifies by address.
static wxString SanitizeFileName(const std::string &aName)
std::map< std::string, std::string > m_globalNetNames
int fontHeightDbu(int aFontIdx, bool aTemplateFont=true) const
|lfHeight| of a Design Template font ID; ID 0 selects the template default.
void appendNetIntent(SCH_SCREEN *aScreen, SCH_LABEL *aLabel, bool aExplicitName, uint32_t aNetId=0)
std::set< std::string > m_powerNetNames
std::string effectiveInterfaceNetName(const std::string &aName) const
std::map< std::string, std::string > effectiveProps(const ORCAD_PLACED_INSTANCE &aInst, const ORCAD_SYMBOL_DEF &aDef) const
Empty package and placement values must not clear a library property.
void placeOffpageConnectors(const ORCAD_RAW_PAGE &aPage, SCH_SCREEN *aScreen, const SCH_SHEET_PATH &aSheetPath, bool aHierarchical)
Keep computed intersheet references hidden; display the stored OrCAD IREF text.
A progress reporter interface for use in multi-threaded environments.
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Holds all the data relating to one schematic.
Definition schematic.h:148
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:165
Segment description base class to describe items which have 2 end points (track, wire,...
Definition sch_line.h:39
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition sch_sheet.h:48
Schematic symbol object.
Definition sch_symbol.h:75
FILL_T
Definition eda_fill.h:29
constexpr ORCAD_ORIENT_ENTRY ORCAD_ORIENT_TABLE[8]
Indexed by orientation bits: angle, mirror, offset selectors, then matrix coefficients.
int OrcadDisplayType(const ORCAD_DISPLAY_PROP &aProp)
VECTOR2I OrcadDbuToIu(int aX, int aY)
bool OrcadDisplayPropShowsName(const ORCAD_DISPLAY_PROP &aProp)
FILL_T OrcadFillType(int aFillStyle, int aHatchStyle)
VECTOR2I OrcadTransformPoint(int aOrient, int aWidth, int aHeight, int aBaseX, int aBaseY, int aPx, int aPy)
Parts use the instance anchor as the base.
int OrcadOrientDim(int aSelector, int aWidth, int aHeight)
int OrcadLineWidthIu(int aWidth)
std::pair< double, double > OrcadDashRatios(int aFormatVersionMajor)
int OrcadTextBaselineOffset(int aTextSize)
std::vector< SEG > OrcadHatchLines(const EDA_SHAPE &aShape, int aHatchStyle, int aPitch)
int OrcadPageOrder(wxString &aName)
Return a numeric page prefix (or -1); strip only the "N - title" convention.
int OrcadHatchPitchIu(uint32_t aModifyTimestamp)
bool OrcadDisplayPropShowsValue(const ORCAD_DISPLAY_PROP &aProp)
int OrcadHatchLineWidthIu(uint32_t aModifyTimestamp)
KIGFX::COLOR4D OrcadColor(int aColorIndex)
int OrcadOrientOf(int aRotation, bool aMirror)
Compose the 3-bit orientation code from the rotation bits and mirror bit.
int OrcadDisplayFontId(const ORCAD_DISPLAY_PROP &aProp)
wxString OrcadPinNameMarkup(const wxString &aName)
constexpr int ORCAD_IU_PER_DBU
Schematic internal units per OrCAD DBU: 10 mil * 254 IU/mil.
bool OrcadDisplayPropVisible(const ORCAD_DISPLAY_PROP &aProp)
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).
int OrcadPageGraphicLineWidthIu(int aWidth)
VECTOR2I OrcadStretchedImageSize(int aWidth, int aHeight, int aBoxWidth, int aBoxHeight)
LINE_STYLE
Dashed line types.
The owning wire defines the connection.
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::string footprint
bool isPower
std::vector< UNIT_INFO > units
sorted by letter; unit numbers are 1-based indices
std::string refPrefix
std::string powerNet
power symbols are keyed by NET name
One resolved off-page connector: index into page.offpage, net, pin position.
– shared bookkeeping types ------------------------------------------------—
std::vector< int > pinOffsets
hidden duplicate-pin electrical offsets, DBU
std::vector< bool > pinIgnore
package pins suppressed for this unit
const ORCAD_SYMBOL_DEF * symbol
std::vector< bool > explicitPinNets
placed pins whose source net overrides implicit power naming
std::vector< std::string > pinNumbers
device pin-number map for this unit
std::string letter
unit discriminator, e.g. "A", "-16", "B:Convert"
bool operator==(const UNIT_INFO &) const =default
std::vector< bool > pinNumberVisible
nonblank source package pin numbers
Child-folder pages are instantiated for each occurrence, with that occurrence's references.
Display positions use symbol coordinates; rotFont combines the font index and quarter turns.
The inline LibraryPart defines the block interface; placed pin records supply absolute positions.
Free graphics use nested primitive coordinates.
OrCAD rotates about the bounding box; KiCad rotates about the anchor.
char mirror
0 = none, 'x' or 'y' = KiCad mirror axis
int8_t tySel
Y offset selector.
int8_t c
int8_t a
int angle
KiCad placement angle in degrees (0/90/180/270, CCW)
int8_t d
int8_t txSel
X offset selector.
int8_t b
The placed box includes displayed text.
Primitive byte lengths can include or exclude the eight-byte size envelope.
Wire IDs refer to netmap, which supplies the source net names.
The bounding box occupies the final eight bytes before the next prefix stop.
Pin coordinates use symbol space with Y down.
The wire ID refers to the page net table.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683