|
KiCad PCB EDA Suite
|
Parser for DipTrace .dch schematic binary files. More...
#include <diptrace_sch_parser.h>
Public Member Functions | |
| SCH_PARSER (const wxString &aFileName, SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, PROGRESS_REPORTER *aProgressReporter=nullptr, REPORTER *aReporter=nullptr) | |
| ~SCH_PARSER () | |
| void | Parse () |
| Parse the .dch file and populate the schematic with KiCad objects. | |
| int | ComponentBoundaryScanCount () const |
Private Member Functions | |
| void | parseHeader () |
| void | parseSheetDefinitions () |
| void | parseDisplaySettings () |
| void | parseTextStyles () |
| void | parsePreComponentSettings () |
| void | parseComponents (size_t aBusSectionOffset) |
| void | parseOneComponent (size_t aCompEnd, bool aUseCompEnd=true) |
| void | parsePin (int aPinIndex, DCH_COMPONENT &aComp) |
| void | parseShape (DCH_COMPONENT &aComp) |
| void | parseFontBearingShape (DCH_COMPONENT &aComp) |
| bool | parseComponentTextField (DCH_COMPONENT &aComp, size_t aCompEnd) |
| void | parseEmbeddedPattern (DCH_COMPONENT &aComp, size_t aCompEnd) |
| void | parseBusSection () |
| void | parseNetSection () |
| void | parseWireSection () |
| void | parseSheetShapes () |
| void | findPageGeometry () |
| Locate the page-geometry record (width/height/margins, each mm*30000) in the binary and fill m_page. | |
| VECTOR2I | applyPageOffset (const VECTOR2I &aPos) const |
| Apply the page-center offset to an absolute KiCad-nm placement so 0,0-centered DipTrace content lands on the top-left-origin KiCad page. | |
| size_t | findBusSection (size_t aSearchStart) const |
| Find the bus section start offset by searching for the characteristic marker pattern: int4(10000) int4(10000) byte(0) byte(0) int3(count). | |
| size_t | findTailStart () const |
| Find where the int3(0) tail padding begins by scanning backward from the end of file. | |
| std::vector< size_t > | scanComponentBoundaries (size_t aFirstComp, size_t aBusSectionOffset) const |
| Pre-scan the file to find component start offsets using the bbox(4*int4) + 5-string pattern. | |
| bool | isShapeStart (size_t aOffset) const |
| Check if the data at the given offset looks like a shape/polyline start. | |
| bool | isFontBearingShapeStart (size_t aOffset) const |
| void | createKiCadObjects () |
| Create KiCad objects from the parsed intermediate data and add them to the appropriate schematic sheets. | |
| SCH_SCREEN * | getOrCreateSheet (int aSheetIndex) |
| Get or create the KiCad sheet and screen for the given DipTrace sheet index. | |
| void | finalizeFlatSheetOrder () |
| void | assignSheetPageNumbers () |
| LIB_SYMBOL * | getOrCreateLibSymbol (const DCH_COMPONENT &aComp, int aUnit) |
| Create a LIB_SYMBOL from the DipTrace component data. | |
| void | populateLibSymbolUnit (LIB_SYMBOL *aLibSymbol, const DCH_COMPONENT &aComp, int aUnit) |
| void | syncEmbeddedLibrarySymbols () |
| wxString | componentSymbolName (const DCH_COMPONENT &aComp) const |
| Library symbol name for a component. | |
| wxString | normalizedRefdes (const DCH_COMPONENT &aComp) const |
| void | createSymbolInstance (const DCH_COMPONENT &aComp, SCH_SCREEN *aFallbackScreen) |
| Create a SCH_SYMBOL instance on the given screen from a DipTrace component. | |
| void | createNetPortLabels () |
| Create a global net label for every DipTrace net-port component (auto_net_ports library). | |
| int | sheetForNearestWire (const VECTOR2I &aPos) const |
| Sheet whose decoded wire geometry is closest to aPos, or -1 when no wire exists. | |
| void | createWires () |
| Emit SCH_LINE wire segments decoded from the net/wire section. | |
| void | createSheetShapes () |
| void | createJunctions () |
| Synthesize junctions where conductors coincide (DipTrace stores none explicitly). | |
| void | buildWirePointSheets () |
| Build the maps from wire-point position to the sheet(s) and part(s) connecting there, and the part-id -> sheet map used for deterministic sheet assignment. | |
| void | buildComponentPartIds () |
| Enumerate every component header in the file (real components and net ports alike) so each component's file offset maps to its DipTrace part id. | |
| bool | isComponentHeaderAt (size_t aOffset) const |
| True if a component record header (placement + five header strings) starts at aOffset. | |
| int | sheetForPositions (const std::vector< VECTOR2I > &aPositions, int aFallback) const |
| Pick the sheet a placed item belongs to by matching its connection points against the decoded wire geometry (DipTrace does not store a per-component sheet field). | |
| int | sheetForComponentPins (const std::vector< VECTOR2I > &aConnectionPoints) |
| Resolve a symbol's sheet from its pin connection points. | |
| int | resolveSheetTally (const std::map< std::pair< int, int >, int > &aTally) |
| Resolve a (partId, sheet) -> hit-count tally to a sheet, preferring the highest-count pair with a part id greater than the last assigned (monotonic). | |
| wxString | getLibName () const |
| Build a library name string for the import. | |
Static Private Member Functions | |
| static int | pinOrientationFromOffset (int aOffsetX, int aOffsetY, int aHalfWidth, int aHalfHeight) |
| Determine the pin orientation from the pin connection-point offset relative to the symbol body center. | |
| static int | toKiCadCoordX (int aDipTraceCoord) |
| Convert a DipTrace coordinate to KiCad schematic internal units. | |
| static int | toKiCadCoordY (int aDipTraceCoord) |
| static int | toKiCadSize (int aDipTraceCoord) |
| Convert a DipTrace length or stroke width to KiCad schematic internal units. | |
Private Attributes | |
| BINARY_READER | m_reader |
| SCHEMATIC * | m_schematic |
| SCH_SHEET * | m_rootSheet |
| PROGRESS_REPORTER * | m_progressReporter |
| REPORTER * | m_reporter |
| int | m_version |
| int | m_magicMajor |
| int | m_componentCount |
| int | m_componentBoundaryScanCount = 0 |
| wxString | m_fileName |
| int | m_numSheets |
| std::vector< DCH_SHEET_DEF > | m_sheetDefs |
| std::vector< DCH_COMPONENT > | m_components |
| std::vector< DCH_BUS_ENTRY > | m_buses |
| std::vector< DCH_NET_ENTRY > | m_nets |
| std::vector< DCH_WIRE > | m_wires |
| std::vector< DCH_SHEET_SHAPE > | m_sheetShapes |
| std::map< std::pair< int, int >, std::set< int > > | m_wirePointSheets |
| Wire-point position (KiCad nm) -> set of sheet indices carrying a wire there. | |
| std::map< std::pair< int, int >, std::vector< std::pair< int, int > > > | m_pointPartSheets |
| Wire-endpoint position (KiCad nm) -> (partId, sheet) pairs of the parts connecting there. | |
| int | m_lastSymbolPartId = -1 |
| Largest part id assigned to a symbol so far; enforces the monotonic part-id order used to disambiguate identical duplicate sheets. | |
| DCH_PAGE | m_page |
| Decoded page geometry and the resulting half-page placement offset (KiCad nm). | |
| VECTOR2I | m_pageOffset |
| size_t | m_componentSectionStart = 0 |
| File offset of the component section start, used to enumerate components in part-id order. | |
| size_t | m_wireSectionEnd = 0 |
| End offset of the decoded wire section; the sheet-shape section follows it in modern files. | |
| std::map< size_t, int > | m_offsetToPartId |
| Component start offset -> DipTrace part id (its index in the in-file component order). | |
| std::map< int, int > | m_partIdSheet |
| DipTrace part id -> sheet index, resolved from the wire connectivity. | |
| std::set< wxString > | m_netPortNames |
| Names of nets that own a placed net-port component; these are the only nets DipTrace draws a label for, so they are the only labels emitted (createNetPortLabels). | |
| size_t | m_netPortLabelCount = 0 |
| Count of net-port labels emitted, for the import summary report. | |
| std::vector< SCH_SHEET * > | m_sheets |
| One per DipTrace sheet. | |
| std::map< wxString, std::unique_ptr< LIB_SYMBOL > > | m_libSymbols |
| Symbol library cache. | |
| std::map< wxString, std::vector< SCH_SYMBOL * > > | m_placedSymbolsByLibName |
| std::map< wxString, int > | m_refdesUnitMap |
| Map from refdes to the number of units already created for multi-unit symbols. | |
| size_t | m_busSectionOffset |
| size_t | m_tailOffset |
Parser for DipTrace .dch schematic binary files.
Reads the binary file using DIPTRACE::BINARY_READER, populates intermediate data structures, then creates KiCad schematic objects (SCH_SYMBOL, SCH_LINE, SCH_LABEL, SCH_SHEET, LIB_SYMBOL).
Supports format versions 31 through 49.
Definition at line 238 of file diptrace_sch_parser.h.
| SCH_PARSER::SCH_PARSER | ( | const wxString & | aFileName, |
| SCHEMATIC * | aSchematic, | ||
| SCH_SHEET * | aRootSheet, | ||
| PROGRESS_REPORTER * | aProgressReporter = nullptr, | ||
| REPORTER * | aReporter = nullptr ) |
| aFileName | path to the DipTrace .dch file. |
| aSchematic | the KiCad schematic object being populated. |
| aRootSheet | the root sheet to populate. |
| aProgressReporter | optional progress reporter (may be nullptr). |
| aReporter | optional message reporter (may be nullptr). |
Definition at line 78 of file diptrace_sch_parser.cpp.
References m_busSectionOffset, m_componentCount, m_fileName, m_magicMajor, m_numSheets, m_progressReporter, m_reader, m_reporter, m_rootSheet, m_schematic, m_tailOffset, and m_version.
| SCH_PARSER::~SCH_PARSER | ( | ) |
Definition at line 96 of file diptrace_sch_parser.cpp.
Apply the page-center offset to an absolute KiCad-nm placement so 0,0-centered DipTrace content lands on the top-left-origin KiCad page.
A no-op when no page was decoded.
Definition at line 181 of file diptrace_sch_parser.cpp.
References m_page, and m_pageOffset.
Referenced by buildWirePointSheets(), createJunctions(), createNetPortLabels(), createSheetShapes(), createSymbolInstance(), and createWires().
|
private |
Definition at line 2437 of file diptrace_sch_parser.cpp.
References SCH_SHEET::GetScreen(), SCH_SHEET::IsVirtualRootSheet(), m_sheets, path, and BASE_SCREEN::SetPageNumber().
Referenced by finalizeFlatSheetOrder().
|
private |
Enumerate every component header in the file (real components and net ports alike) so each component's file offset maps to its DipTrace part id.
Fills m_offsetToPartId.
Definition at line 2963 of file diptrace_sch_parser.cpp.
References isComponentHeaderAt(), m_busSectionOffset, m_componentSectionStart, and m_offsetToPartId.
Referenced by createKiCadObjects().
|
private |
Build the maps from wire-point position to the sheet(s) and part(s) connecting there, and the part-id -> sheet map used for deterministic sheet assignment.
Definition at line 2820 of file diptrace_sch_parser.cpp.
References applyPageOffset(), m_numSheets, m_partIdSheet, m_pointPartSheets, m_wirePointSheets, m_wires, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by createKiCadObjects().
|
inline |
Definition at line 260 of file diptrace_sch_parser.h.
References m_componentBoundaryScanCount.
Referenced by BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().
|
private |
Library symbol name for a component.
Multi-part components group by normalized reference so their units share one symbol. Single-part symbols keep a rotation suffix because their pin and shape coordinates are stored already rotated.
Definition at line 2505 of file diptrace_sch_parser.cpp.
References DIPTRACE::DCH_COMPONENT::compName, LIB_ID::FixIllegalChars(), DIPTRACE::DCH_COMPONENT::isMultiPart, normalizedRefdes(), DIPTRACE::DCH_COMPONENT::rotationE4, and UTF8::wx_str().
Referenced by createSymbolInstance(), and getOrCreateLibSymbol().
|
private |
Synthesize junctions where conductors coincide (DipTrace stores none explicitly).
Definition at line 4074 of file diptrace_sch_parser.cpp.
References applyPageOffset(), getOrCreateSheet(), m_numSheets, m_rootSheet, m_sheets, m_wires, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by createKiCadObjects().
|
private |
Create KiCad objects from the parsed intermediate data and add them to the appropriate schematic sheets.
Definition at line 4182 of file diptrace_sch_parser.cpp.
References _, buildComponentPartIds(), buildWirePointSheets(), comp, createJunctions(), createNetPortLabels(), createSheetShapes(), createSymbolInstance(), createWires(), finalizeFlatSheetOrder(), getOrCreateSheet(), m_buses, m_components, m_lastSymbolPartId, m_netPortLabelCount, m_numSheets, m_page, m_placedSymbolsByLibName, m_refdesUnitMap, m_reporter, m_rootSheet, m_sheetDefs, m_sheets, m_version, name, RPT_SEVERITY_INFO, RPT_SEVERITY_WARNING, PAGE_INFO::SetHeightMM(), PAGE_INFO::SetWidthMM(), syncEmbeddedLibrarySymbols(), and User.
Referenced by Parse().
|
private |
Create a global net label for every DipTrace net-port component (auto_net_ports library).
The label name is the port's component name (which equals its net name) and its placement is the port's stored bbox center, so ports without an explicit wire still appear. This is the only label source; internal auto-named nets own no port object and so carry no label, matching the DipTrace rendering. Fills m_netPortNames and m_netPortLabelCount.
Definition at line 3408 of file diptrace_sch_parser.cpp.
References std::abs(), SCH_SCREEN::Append(), applyPageOffset(), SPIN_STYLE::BOTTOM, comp, getOrCreateSheet(), L_BIDI, SPIN_STYLE::LEFT, DIPTRACE::DCH_PIN::length, m_components, m_lastSymbolPartId, m_netPortLabelCount, m_netPortNames, m_offsetToPartId, m_partIdSheet, SPIN_STYLE::RIGHT, SCH_LABEL_BASE::SetShape(), SCH_GLOBALLABEL::SetSpinStyle(), sheetForComponentPins(), sheetForNearestWire(), toKiCadCoordX(), toKiCadCoordY(), toKiCadSize(), SPIN_STYLE::UP, DIPTRACE::DCH_PIN::x, VECTOR2< T >::x, DIPTRACE::DCH_PIN::y, and VECTOR2< T >::y.
Referenced by createKiCadObjects().
|
private |
Definition at line 4001 of file diptrace_sch_parser.cpp.
References SCH_SHAPE::AddPoint(), SCH_SCREEN::Append(), applyPageOffset(), dipTraceSheetShapeColor(), getOrCreateSheet(), LAYER_NOTES, m_sheetShapes, NO_FILL, POLY, RECTANGLE, EDA_SHAPE::SetEnd(), SCH_SHAPE::SetPosition(), SCH_SHAPE::SetStroke(), SOLID, toKiCadCoordX(), toKiCadCoordY(), toKiCadSize(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by createKiCadObjects().
|
private |
Create a SCH_SYMBOL instance on the given screen from a DipTrace component.
Definition at line 3087 of file diptrace_sch_parser.cpp.
References std::abs(), SCH_SYMBOL::AddField(), DIPTRACE::DCH_COMPONENT::additionalFields, ANGLE_VERTICAL, SCH_SCREEN::Append(), applyPageOffset(), DIPTRACE::DCH_COMPONENT::bboxX1, DIPTRACE::DCH_COMPONENT::bboxY1, center, DIPTRACE::DCH_COMPONENT::compName, componentSymbolName(), DIPTRACE::DCH_COMPONENT_TEXT::coordX, DIPTRACE::DCH_COMPONENT_TEXT::coordY, DATASHEET, DIPTRACE::DCH_COMPONENT::datasheet, DIPTRACE::DCH_COMPONENT::fileOffset, LIB_SYMBOL::GetBodyBoundingBox(), BOX2< Vec >::GetBottom(), SCH_SYMBOL::GetField(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetLeft(), getLibName(), getOrCreateLibSymbol(), getOrCreateSheet(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), BOX2< Vec >::GetWidth(), GR_TEXT_H_ALIGN_CENTER, GR_TEXT_H_ALIGN_LEFT, GR_TEXT_H_ALIGN_RIGHT, GR_TEXT_V_ALIGN_CENTER, DIPTRACE::DCH_PIN::length, DIPTRACE::DCH_COMPONENT::libPath, m_offsetToPartId, m_partIdSheet, m_placedSymbolsByLibName, m_refdesUnitMap, m_schematic, normalizedRefdes(), DIPTRACE::DCH_COMPONENT::patternName, DIPTRACE::DCH_COMPONENT::pins, DIPTRACE::DCH_COMPONENT::refdes, REFERENCE, DIPTRACE::DCH_COMPONENT::rotationE4, schIUScale, SCH_SYMBOL::SetFootprintFieldText(), SCH_SYMBOL::SetLibSymbol(), SCH_FIELD::SetPosition(), SCH_SYMBOL::SetRef(), SCH_FIELD::SetText(), EDA_TEXT::SetVisible(), sheetForComponentPins(), DIPTRACE::DCH_COMPONENT::texts, toKiCadCoordX(), toKiCadCoordY(), toKiCadSize(), DIPTRACE::DCH_COMPONENT_TEXT::type, USER, VALUE, DIPTRACE::DCH_COMPONENT::value, DIPTRACE::DCH_PIN::x, VECTOR2< T >::x, DIPTRACE::DCH_PIN::y, and VECTOR2< T >::y.
Referenced by createKiCadObjects().
|
private |
Emit SCH_LINE wire segments decoded from the net/wire section.
Definition at line 4044 of file diptrace_sch_parser.cpp.
References SCH_SCREEN::Append(), applyPageOffset(), getOrCreateSheet(), LAYER_WIRE, m_numSheets, m_wires, and SCH_LINE::SetEndPoint().
Referenced by createKiCadObjects().
|
private |
Definition at line 2460 of file diptrace_sch_parser.cpp.
References assignSheetPageNumbers(), m_rootSheet, m_schematic, and m_sheets.
Referenced by createKiCadObjects().
|
private |
Find the bus section start offset by searching for the characteristic marker pattern: int4(10000) int4(10000) byte(0) byte(0) int3(count).
Definition at line 446 of file diptrace_sch_parser.cpp.
References _, DIPTRACE::INT3_BIAS, m_reader, and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Locate the page-geometry record (width/height/margins, each mm*30000) in the binary and fill m_page.
The record is not present in every file; m_page.found stays false when absent.
Definition at line 123 of file diptrace_sch_parser.cpp.
References DIPTRACE::INT4_BIAS, m_page, m_pageOffset, m_reader, and toKiCadSize().
Referenced by Parse().
|
private |
Find where the int3(0) tail padding begins by scanning backward from the end of file.
Definition at line 477 of file diptrace_sch_parser.cpp.
References m_reader.
Referenced by Parse().
|
private |
Build a library name string for the import.
Definition at line 190 of file diptrace_sch_parser.cpp.
References LIB_ID::FixIllegalChars(), m_rootSheet, m_schematic, and UTF8::wx_str().
Referenced by createSymbolInstance().
|
private |
Create a LIB_SYMBOL from the DipTrace component data.
If a library symbol with the same name already exists, returns the existing one (handles multi-unit symbols by adding units).
Definition at line 2778 of file diptrace_sch_parser.cpp.
References componentSymbolName(), LIB_SYMBOL::GetUnitCount(), m_libSymbols, DIPTRACE::DCH_COMPONENT::patternName, DIPTRACE::DCH_COMPONENT::pins, populateLibSymbolUnit(), DIPTRACE::DCH_COMPONENT::refdes, and LIB_SYMBOL::SetUnitCount().
Referenced by createSymbolInstance().
|
private |
Get or create the KiCad sheet and screen for the given DipTrace sheet index.
Definition at line 2390 of file diptrace_sch_parser.cpp.
References FILEEXT::KiCadSchematicFileExtension, m_fileName, m_numSheets, m_rootSheet, m_schematic, m_sheetDefs, m_sheets, SCH_SCREEN::SetFileName(), SCH_SHEET::SetFileName(), SCH_SHEET::SetName(), and SCH_SHEET::SetScreen().
Referenced by createJunctions(), createKiCadObjects(), createNetPortLabels(), createSheetShapes(), createSymbolInstance(), and createWires().
|
private |
True if a component record header (placement + five header strings) starts at aOffset.
Looser than scanComponentBoundaries so net ports are enumerated too.
Definition at line 2882 of file diptrace_sch_parser.cpp.
References std::abs(), DIPTRACE::INT3_BIAS, DIPTRACE::INT4_BIAS, m_reader, m_version, and SCHEMATIC_UTF16_STRING_VERSION.
Referenced by buildComponentPartIds(), parseEmbeddedPattern(), parseOneComponent(), and scanComponentBoundaries().
|
private |
Definition at line 582 of file diptrace_sch_parser.cpp.
References DIPTRACE::INT3_BIAS, DIPTRACE::INT4_BIAS, m_reader, m_version, TAHOMA_FONT_PATTERN, and V31_CUTOVER.
Referenced by parseOneComponent().
|
private |
Check if the data at the given offset looks like a shape/polyline start.
Definition at line 531 of file diptrace_sch_parser.cpp.
References DIPTRACE::INT3_BIAS, DIPTRACE::INT4_BIAS, m_reader, m_version, and V31_CUTOVER.
Referenced by parseOneComponent().
|
private |
Definition at line 2484 of file diptrace_sch_parser.cpp.
References DIPTRACE::DCH_COMPONENT::isMultiPart, and DIPTRACE::DCH_COMPONENT::refdes.
Referenced by componentSymbolName(), and createSymbolInstance().
| void SCH_PARSER::Parse | ( | ) |
Parse the .dch file and populate the schematic with KiCad objects.
| IO_ERROR | on fatal parse errors. |
Definition at line 209 of file diptrace_sch_parser.cpp.
References _, createKiCadObjects(), findBusSection(), findPageGeometry(), findTailStart(), DIPTRACE::LEGACY_ASCII, m_busSectionOffset, m_magicMajor, m_numSheets, m_reader, m_tailOffset, m_version, parseBusSection(), parseComponents(), parseDisplaySettings(), parseHeader(), parseNetSection(), parsePreComponentSettings(), parseSheetDefinitions(), parseSheetShapes(), parseTextStyles(), parseWireSection(), SCHEMATIC_UTF16_STRING_VERSION, THROW_IO_ERROR, and DIPTRACE::UTF16_BE.
Referenced by BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and SCH_IO_DIPTRACE::LoadSchematicFile().
|
private |
Definition at line 2188 of file diptrace_sch_parser.cpp.
References _, DIPTRACE::DCH_BUS_ENTRY::busType, DIPTRACE::DCH_BUS_ENTRY::coordX, DIPTRACE::DCH_BUS_ENTRY::coordY, DIPTRACE::DCH_BUS_ENTRY::instanceId, m_buses, m_reader, DIPTRACE::DCH_BUS_ENTRY::name, DIPTRACE::DCH_BUS_ENTRY::sheetIndex, DIPTRACE::DCH_BUS_ENTRY::signalCount, and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Definition at line 623 of file diptrace_sch_parser.cpp.
References _, m_componentBoundaryScanCount, m_componentCount, m_components, m_componentSectionStart, m_reader, parseOneComponent(), scanComponentBoundaries(), and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Definition at line 1645 of file diptrace_sch_parser.cpp.
References DIPTRACE::INT3_BIAS, m_reader, text, and DIPTRACE::DCH_COMPONENT::texts.
Referenced by parseOneComponent().
|
private |
Definition at line 340 of file diptrace_sch_parser.cpp.
References m_reader, m_version, and V31_CUTOVER.
Referenced by Parse().
|
private |
Definition at line 1703 of file diptrace_sch_parser.cpp.
References _, DIPTRACE::INT3_BIAS, isComponentHeaderAt(), m_busSectionOffset, m_reader, m_version, DIPTRACE::DCH_COMPONENT::patternName, save, THROW_IO_ERROR, and V31_CUTOVER.
Referenced by parseOneComponent().
|
private |
Definition at line 1607 of file diptrace_sch_parser.cpp.
References DIPTRACE::DCH_SHAPE::fontX, DIPTRACE::DCH_SHAPE::fontY, DIPTRACE::DCH_SHAPE::kindCode, DIPTRACE::DCH_SHAPE::kindFlag, DIPTRACE::DCH_SHAPE::lineWidth, m_reader, DIPTRACE::DCH_SHAPE::points, DIPTRACE::DCH_SHAPE::shapeField, and DIPTRACE::DCH_COMPONENT::shapes.
Referenced by parseOneComponent().
|
private |
Definition at line 280 of file diptrace_sch_parser.cpp.
References _, m_magicMajor, m_numSheets, m_reader, m_version, and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Definition at line 2247 of file diptrace_sch_parser.cpp.
References DIPTRACE::DCH_NET_ENTRY::coordX, DIPTRACE::DCH_NET_ENTRY::coordY, DIPTRACE::DCH_NET_ENTRY::field1, DIPTRACE::INT3_BIAS, DIPTRACE::INT4_BIAS, m_nets, m_reader, m_tailOffset, m_version, DIPTRACE::DCH_NET_ENTRY::name, name, and V31_CUTOVER.
Referenced by Parse().
|
private |
Definition at line 704 of file diptrace_sch_parser.cpp.
References _, comp, DIPTRACE::DCH_COMPONENT_TEXT::coordX, DIPTRACE::DCH_COMPONENT_TEXT::coordY, DIPTRACE::DCH_COMPONENT_TEXT::fieldA, DIPTRACE::DCH_COMPONENT_TEXT::flags, DIPTRACE::DCH_COMPONENT_TEXT::fontName, DIPTRACE::DCH_COMPONENT_TEXT::fontSize, DIPTRACE::INT3_BIAS, DIPTRACE::INT4_BIAS, isComponentHeaderAt(), isFontBearingShapeStart(), isShapeStart(), m_busSectionOffset, m_components, m_reader, m_reporter, m_version, parseComponentTextField(), parseEmbeddedPattern(), parseFontBearingShape(), parsePin(), parseShape(), RPT_SEVERITY_INFO, save, DIPTRACE::DCH_COMPONENT_TEXT::text, THROW_IO_ERROR, DIPTRACE::DCH_COMPONENT_TEXT::type, and V31_CUTOVER.
Referenced by parseComponents().
|
private |
Definition at line 1457 of file diptrace_sch_parser.cpp.
References m_reader, m_version, pin, DIPTRACE::DCH_COMPONENT::pins, and V31_CUTOVER.
Referenced by parseOneComponent().
|
private |
Definition at line 403 of file diptrace_sch_parser.cpp.
References _, DIPTRACE::LEGACY_STRING_VERSION, m_componentCount, m_magicMajor, m_reader, m_version, and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Definition at line 1547 of file diptrace_sch_parser.cpp.
References DIPTRACE::DCH_SHAPE::flags, DIPTRACE::DCH_SHAPE::fontX, DIPTRACE::DCH_SHAPE::fontY, DIPTRACE::INT3_BIAS, DIPTRACE::DCH_SHAPE::kindCode, DIPTRACE::DCH_SHAPE::kindFlag, DIPTRACE::DCH_SHAPE::lineWidth, m_reader, m_version, DIPTRACE::DCH_SHAPE::points, DIPTRACE::DCH_SHAPE::shapeField, DIPTRACE::DCH_COMPONENT::shapes, and V31_CUTOVER.
Referenced by parseOneComponent().
|
private |
Definition at line 328 of file diptrace_sch_parser.cpp.
References DIPTRACE::DCH_SHEET_DEF::field_a, m_numSheets, m_reader, m_sheetDefs, and DIPTRACE::DCH_SHEET_DEF::name.
Referenced by Parse().
|
private |
Definition at line 3872 of file diptrace_sch_parser.cpp.
References DIPTRACE::DCH_SHEET_SHAPE::color, DIPTRACE::DCH_SHEET_SHAPE::kindCode, DIPTRACE::DCH_SHEET_SHAPE::lineWidth, m_busSectionOffset, m_numSheets, m_reader, m_sheetShapes, m_tailOffset, m_version, m_wireSectionEnd, DIPTRACE::DCH_SHEET_SHAPE::points, DIPTRACE::DCH_SHEET_SHAPE::sheetIndex, and V31_CUTOVER.
Referenced by Parse().
|
private |
Definition at line 373 of file diptrace_sch_parser.cpp.
References _, DIPTRACE::LEGACY_STRING_VERSION, m_magicMajor, m_reader, m_version, and THROW_IO_ERROR.
Referenced by Parse().
|
private |
Definition at line 3607 of file diptrace_sch_parser.cpp.
References _, DIPTRACE::DCH_WIRE::bus1, DIPTRACE::DCH_WIRE::bus2, DIPTRACE::INT3_BIAS, DIPTRACE::INT4_BIAS, isPlausibleNetName(), m_busSectionOffset, m_reader, m_tailOffset, m_version, m_wires, m_wireSectionEnd, DIPTRACE::DCH_WIRE::object1, DIPTRACE::DCH_WIRE::object2, DIPTRACE::DCH_WIRE::points, SCHEMATIC_UTF16_STRING_VERSION, DIPTRACE::DCH_WIRE::sheetIndex, DIPTRACE::DCH_WIRE::subObject1, DIPTRACE::DCH_WIRE::subObject2, THROW_IO_ERROR, toKiCadCoordX(), and toKiCadCoordY().
Referenced by Parse().
|
staticprivate |
Determine the pin orientation from the pin connection-point offset relative to the symbol body center.
DipTrace stores the connection point and a length; the body extends inward, so a pin on the right side of the body points left, and so on. Returns a KiCad orientation code (0 = right, 1 = up, 2 = left, 3 = down).
Definition at line 2362 of file diptrace_sch_parser.cpp.
References std::abs().
Referenced by populateLibSymbolUnit().
|
private |
Definition at line 2593 of file diptrace_sch_parser.cpp.
References std::abs(), LIB_SYMBOL::AddDrawItem(), anchor, ARC, DIPTRACE::DCH_COMPONENT::bboxX2, DIPTRACE::DCH_COMPONENT::bboxY2, center, CIRCLE, circle(), componentShapes, end, FILLED_SHAPE, LAYER_DEVICE, DIPTRACE::DCH_PIN::length, libSymbolHasUnit(), DIPTRACE::DCH_PIN::name, needsStandardThtLedShape(), NO_FILL, DIPTRACE::DCH_PIN::number, pin, PIN_DOWN, PIN_LEFT, PIN_RIGHT, PIN_UP, pinOrientationFromOffset(), DIPTRACE::DCH_COMPONENT::pins, POLY, PT_PASSIVE, PT_POWER_IN, radius, RECTANGLE, DIPTRACE::DCH_COMPONENT::refdes, schIUScale, DIPTRACE::DCH_COMPONENT::shapes, SOLID, standardThtLedShapes(), toKiCadCoordX(), toKiCadCoordY(), toKiCadSize(), DIPTRACE::DCH_PIN::x, VECTOR2< T >::x, DIPTRACE::DCH_PIN::y, and VECTOR2< T >::y.
Referenced by getOrCreateLibSymbol().
|
private |
Resolve a (partId, sheet) -> hit-count tally to a sheet, preferring the highest-count pair with a part id greater than the last assigned (monotonic).
Updates m_lastSymbolPartId.
Definition at line 2988 of file diptrace_sch_parser.cpp.
References m_lastSymbolPartId.
Referenced by sheetForComponentPins().
|
private |
Pre-scan the file to find component start offsets using the bbox(4*int4) + 5-string pattern.
Definition at line 502 of file diptrace_sch_parser.cpp.
References end, and isComponentHeaderAt().
Referenced by parseComponents().
|
private |
Resolve a symbol's sheet from its pin connection points.
Wire endpoints carry both a part id and a sheet, so the candidate (partId, sheet) pairs are tallied; on identical/duplicate sheets the tie is broken by the monotonic part-id order (components are stored in part-id order), which selects the correct one of the duplicated sheets. Falls back to position voting, then to the root sheet. Updates m_lastSymbolPartId.
Definition at line 3023 of file diptrace_sch_parser.cpp.
References m_pointPartSheets, resolveSheetTally(), and sheetForPositions().
Referenced by createNetPortLabels(), and createSymbolInstance().
|
private |
Sheet whose decoded wire geometry is closest to aPos, or -1 when no wire exists.
Used as the final fallback for an isolated net port whose pin matched no wire and whose part id has no wire-derived sheet.
Definition at line 3527 of file diptrace_sch_parser.cpp.
References m_wirePointSheets, VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by createNetPortLabels().
|
private |
Pick the sheet a placed item belongs to by matching its connection points against the decoded wire geometry (DipTrace does not store a per-component sheet field).
Returns the majority-voted sheet, or aFallback when no point coincides with a wire.
Definition at line 3053 of file diptrace_sch_parser.cpp.
References m_wirePointSheets.
Referenced by sheetForComponentPins().
|
private |
Definition at line 4164 of file diptrace_sch_parser.cpp.
References m_libSymbols, and m_placedSymbolsByLibName.
Referenced by createKiCadObjects().
|
staticprivate |
Convert a DipTrace coordinate to KiCad schematic internal units.
One DipTrace coordinate unit is 100/3 nm and one schematic IU is 100 nm, so the conversion divides by 3. The PCB importer shares the 100/3 nm unit but multiplies by 100/3 because pcbnew IU is 1 nm.
DipTrace .dch stores schematic Y already in screen-down convention (matching KiCad), with any placement rotation baked into the stored coordinates, so Y is scaled without an axis flip.
Definition at line 101 of file diptrace_sch_parser.cpp.
Referenced by createNetPortLabels(), createSheetShapes(), createSymbolInstance(), parseWireSection(), and populateLibSymbolUnit().
|
staticprivate |
Definition at line 107 of file diptrace_sch_parser.cpp.
Referenced by createNetPortLabels(), createSheetShapes(), createSymbolInstance(), parseWireSection(), and populateLibSymbolUnit().
|
staticprivate |
Convert a DipTrace length or stroke width to KiCad schematic internal units.
Same unit as coordinates but unsigned and without the Y axis flip.
Definition at line 117 of file diptrace_sch_parser.cpp.
References std::abs().
Referenced by createNetPortLabels(), createSheetShapes(), createSymbolInstance(), findPageGeometry(), and populateLibSymbolUnit().
|
private |
Definition at line 459 of file diptrace_sch_parser.h.
Referenced by createKiCadObjects(), and parseBusSection().
|
private |
Definition at line 508 of file diptrace_sch_parser.h.
Referenced by buildComponentPartIds(), Parse(), parseEmbeddedPattern(), parseOneComponent(), parseSheetShapes(), parseWireSection(), and SCH_PARSER().
|
private |
Definition at line 452 of file diptrace_sch_parser.h.
Referenced by ComponentBoundaryScanCount(), and parseComponents().
|
private |
Definition at line 451 of file diptrace_sch_parser.h.
Referenced by parseComponents(), parsePreComponentSettings(), and SCH_PARSER().
|
private |
Definition at line 458 of file diptrace_sch_parser.h.
Referenced by createKiCadObjects(), createNetPortLabels(), parseComponents(), and parseOneComponent().
|
private |
File offset of the component section start, used to enumerate components in part-id order.
Definition at line 481 of file diptrace_sch_parser.h.
Referenced by buildComponentPartIds(), and parseComponents().
|
private |
Definition at line 453 of file diptrace_sch_parser.h.
Referenced by getOrCreateSheet(), and SCH_PARSER().
|
private |
Largest part id assigned to a symbol so far; enforces the monotonic part-id order used to disambiguate identical duplicate sheets.
Definition at line 474 of file diptrace_sch_parser.h.
Referenced by createKiCadObjects(), createNetPortLabels(), and resolveSheetTally().
|
private |
Symbol library cache.
Definition at line 502 of file diptrace_sch_parser.h.
Referenced by getOrCreateLibSymbol(), and syncEmbeddedLibrarySymbols().
|
private |
Definition at line 450 of file diptrace_sch_parser.h.
Referenced by Parse(), parseHeader(), parsePreComponentSettings(), parseTextStyles(), and SCH_PARSER().
|
private |
Count of net-port labels emitted, for the import summary report.
Definition at line 498 of file diptrace_sch_parser.h.
Referenced by createKiCadObjects(), and createNetPortLabels().
|
private |
Names of nets that own a placed net-port component; these are the only nets DipTrace draws a label for, so they are the only labels emitted (createNetPortLabels).
Definition at line 495 of file diptrace_sch_parser.h.
Referenced by createNetPortLabels().
|
private |
Definition at line 460 of file diptrace_sch_parser.h.
Referenced by parseNetSection().
|
private |
Definition at line 456 of file diptrace_sch_parser.h.
Referenced by buildWirePointSheets(), createJunctions(), createKiCadObjects(), createWires(), getOrCreateSheet(), Parse(), parseHeader(), parseSheetDefinitions(), parseSheetShapes(), and SCH_PARSER().
|
private |
Component start offset -> DipTrace part id (its index in the in-file component order).
Definition at line 487 of file diptrace_sch_parser.h.
Referenced by buildComponentPartIds(), createNetPortLabels(), and createSymbolInstance().
|
private |
Decoded page geometry and the resulting half-page placement offset (KiCad nm).
Definition at line 477 of file diptrace_sch_parser.h.
Referenced by applyPageOffset(), createKiCadObjects(), and findPageGeometry().
|
private |
Definition at line 478 of file diptrace_sch_parser.h.
Referenced by applyPageOffset(), and findPageGeometry().
|
private |
DipTrace part id -> sheet index, resolved from the wire connectivity.
This places a symbol on its true sheet even when its pin geometry was mis-parsed.
Definition at line 491 of file diptrace_sch_parser.h.
Referenced by buildWirePointSheets(), createNetPortLabels(), and createSymbolInstance().
|
private |
Definition at line 503 of file diptrace_sch_parser.h.
Referenced by createKiCadObjects(), createSymbolInstance(), and syncEmbeddedLibrarySymbols().
|
private |
Wire-endpoint position (KiCad nm) -> (partId, sheet) pairs of the parts connecting there.
Lets a symbol recover its exact part id and disambiguate duplicate sheets.
Definition at line 470 of file diptrace_sch_parser.h.
Referenced by buildWirePointSheets(), and sheetForComponentPins().
|
private |
Definition at line 447 of file diptrace_sch_parser.h.
Referenced by SCH_PARSER().
|
private |
Definition at line 444 of file diptrace_sch_parser.h.
Referenced by findBusSection(), findPageGeometry(), findTailStart(), isComponentHeaderAt(), isFontBearingShapeStart(), isShapeStart(), Parse(), parseBusSection(), parseComponents(), parseComponentTextField(), parseDisplaySettings(), parseEmbeddedPattern(), parseFontBearingShape(), parseHeader(), parseNetSection(), parseOneComponent(), parsePin(), parsePreComponentSettings(), parseShape(), parseSheetDefinitions(), parseSheetShapes(), parseTextStyles(), parseWireSection(), and SCH_PARSER().
|
private |
Map from refdes to the number of units already created for multi-unit symbols.
Definition at line 506 of file diptrace_sch_parser.h.
Referenced by createKiCadObjects(), and createSymbolInstance().
|
private |
Definition at line 448 of file diptrace_sch_parser.h.
Referenced by createKiCadObjects(), parseOneComponent(), and SCH_PARSER().
|
private |
Definition at line 446 of file diptrace_sch_parser.h.
Referenced by createJunctions(), createKiCadObjects(), finalizeFlatSheetOrder(), getLibName(), getOrCreateSheet(), and SCH_PARSER().
|
private |
Definition at line 445 of file diptrace_sch_parser.h.
Referenced by createSymbolInstance(), finalizeFlatSheetOrder(), getLibName(), getOrCreateSheet(), and SCH_PARSER().
|
private |
Definition at line 457 of file diptrace_sch_parser.h.
Referenced by createKiCadObjects(), getOrCreateSheet(), and parseSheetDefinitions().
|
private |
One per DipTrace sheet.
Definition at line 501 of file diptrace_sch_parser.h.
Referenced by assignSheetPageNumbers(), createJunctions(), createKiCadObjects(), finalizeFlatSheetOrder(), and getOrCreateSheet().
|
private |
Definition at line 462 of file diptrace_sch_parser.h.
Referenced by createSheetShapes(), and parseSheetShapes().
|
private |
Definition at line 509 of file diptrace_sch_parser.h.
Referenced by Parse(), parseNetSection(), parseSheetShapes(), parseWireSection(), and SCH_PARSER().
|
private |
Definition at line 449 of file diptrace_sch_parser.h.
Referenced by createKiCadObjects(), isComponentHeaderAt(), isFontBearingShapeStart(), isShapeStart(), Parse(), parseDisplaySettings(), parseEmbeddedPattern(), parseHeader(), parseNetSection(), parseOneComponent(), parsePin(), parsePreComponentSettings(), parseShape(), parseSheetShapes(), parseTextStyles(), parseWireSection(), and SCH_PARSER().
|
private |
Wire-point position (KiCad nm) -> set of sheet indices carrying a wire there.
Used to recover each symbol's / label's owning sheet, which DipTrace stores only implicitly.
Definition at line 466 of file diptrace_sch_parser.h.
Referenced by buildWirePointSheets(), sheetForNearestWire(), and sheetForPositions().
|
private |
Definition at line 461 of file diptrace_sch_parser.h.
Referenced by buildWirePointSheets(), createJunctions(), createWires(), and parseWireSection().
|
private |
End offset of the decoded wire section; the sheet-shape section follows it in modern files.
Definition at line 484 of file diptrace_sch_parser.h.
Referenced by parseSheetShapes(), and parseWireSection().