|
KiCad PCB EDA Suite
|
#include <target3001_sch_builder.h>
Classes | |
| struct | PIN_END |
| Placed pin of a signal. More... | |
Public Member Functions | |
| TARGET3001_SCH_BUILDER (SCHEMATIC *aSchematic, SCH_SHEET *aRootSheet, const TARGET3001::PROJECT &aProject, const wxString &aFileName, REPORTER *aReporter) | |
| void | Build () |
Private Member Functions | |
| SCH_SCREEN * | screen (int aSheet) |
| Screen for a 1-based sheet number, created on first use. | |
| void | addComponent (const TARGET3001::ELEMENT &aComponent) |
| void | addConnections (const TARGET3001::ELEMENT &aSignal) |
| void | addFreeItem (const TARGET3001::ELEMENT &aElem) |
| void | addFreeSymbol (const TARGET3001::ELEMENT &aSymbol) |
| void | addGateBodies (LIB_SYMBOL *aLib, const std::vector< const TARGET3001::ELEMENT * > &aGates, bool aFieldTexts, const std::map< uint16_t, wxString > &aPadNumbers={}) const |
| Draw each gate's body as one unit of aLib; aFieldTexts leaves reference and value texts to fields. | |
| SCH_ITEM * | makeGraphic (const TARGET3001::ELEMENT &aElem, const VECTOR2I &aOrigin, bool aInSymbol) const |
| Add graphics shared by free items and symbol bodies; returns nullptr for unsupported items. | |
| SCH_BITMAP * | makePicture (const TARGET3001::ELEMENT &aElem) const |
| Image a rectangle shows instead of its fill, or nullptr when it has none. | |
| void | addToSheet (int aSheet, SCH_ITEM *aItem) |
| void | addNetItem (int aSheet, SCH_ITEM *aItem, int aSignal) |
| Add a wire, junction or label of signal aSignal; separateSignals() keeps it apart from other signals. | |
| void | separateSignals (int aSheet) |
| Move apart items of different signals that touch where KiCad would join them, since the file connects items by signal alone. | |
| std::optional< VECTOR2I > | bendAround (int aSheet, int aSignal, const VECTOR2I &aPos, std::vector< std::pair< SCH_LINE *, int > > &aWires, const std::function< bool(const VECTOR2I &)> &aIsFree) |
| Bend the wires of aSignal that pass through aPos around it, one gap aside on a side aIsFree accepts, adding the new pieces to aWires. | |
| bool | joinsGlobally (const TARGET3001::ELEMENT &aSignal) const |
| True when the signal's labels must be global: it reaches several sheets or meets supply symbols. | |
| std::optional< VECTOR2I > | labelAnchor (const TARGET3001::ELEMENT &aSignal, int aSheet, const VECTOR2I &aPos) const |
| Point on the signal's own wires or pins nearest a name drawn at aPos, if it is close enough to name them. | |
| void | joinSignalPieces () |
| Join the pieces of every signal as separateSignals() left them; see joinPieces() | |
| void | joinPieces (int aSignal, const std::map< int, std::vector< SCH_ITEM * > > &aItems) |
| Join the pieces of signal aSignal that KiCad would see apart, since the file joins a signal's items by identity. | |
| void | finishSheets () |
Static Private Member Functions | |
| static int | sheetOf (const TARGET3001::ELEMENT &aElem) |
| Sheet number of a schematic element, or 0 for board elements. | |
| static VECTOR2I | toSch (int32_t aX, int32_t aY) |
| Sheet position in KiCad units, before the per-sheet page offset is applied. | |
| static int | toSch (int32_t aLength) |
Private Attributes | |
| SCHEMATIC * | m_schematic |
| SCH_SHEET * | m_rootSheet |
| const TARGET3001::PROJECT & | m_project |
| wxString | m_fileName |
| REPORTER * | m_reporter |
| std::map< int, SCH_SHEET * > | m_sheets |
| by 1-based sheet number | |
| std::map< int, BOX2I > | m_extents |
| drawn extent of each sheet | |
| std::map< int, std::vector< SCH_ITEM * > > | m_pending |
| int | m_powerCount = 0 |
| int | m_freeSymbolCount = 0 |
| std::map< int, std::set< int > > | m_powerSheets |
| sheets holding a power symbol, by signal ID | |
| std::map< int, std::vector< std::pair< SCH_ITEM *, int > > > | m_netItems |
| items and their signal, by sheet | |
| std::map< int, std::vector< std::pair< VECTOR2I, int > > > | m_pinSignals |
| pin points and signal, by sheet | |
| std::set< int > | m_globalSignals |
| signals joined by global labels | |
| std::map< int, std::vector< PIN_END > > | m_pinEnds |
| placed pins of each signal, by signal ID | |
| int | m_unconnectedPins = 0 |
| TARGET3001::FONTS | m_fonts |
| lookup cache, filled while drawing | |
Definition at line 54 of file target3001_sch_builder.h.
| TARGET3001_SCH_BUILDER::TARGET3001_SCH_BUILDER | ( | SCHEMATIC * | aSchematic, |
| SCH_SHEET * | aRootSheet, | ||
| const TARGET3001::PROJECT & | aProject, | ||
| const wxString & | aFileName, | ||
| REPORTER * | aReporter ) |
Definition at line 269 of file target3001_sch_builder.cpp.
References m_fileName, m_project, m_reporter, m_rootSheet, and m_schematic.
|
private |
Definition at line 550 of file target3001_sch_builder.cpp.
References addGateBodies(), addToSheet(), TARGET3001::ELEMENT::base, TARGET3001::FONTS::BaselineShift(), comp, TARGET3001::ELEMENT::component, TARGET3001::ELEMENT_BASE::component, TARGET3001::PIN::direction, LIB_ID::FixIllegalChars(), TARGET3001::TEXT::function, SCH_SYMBOL::GetField(), LIB_SYMBOL::GetLibId(), LIB_SYMBOL::GetReferenceField(), LIB_SYMBOL::GetValueField(), m_fonts, m_pinEnds, m_pinSignals, m_powerCount, m_powerSheets, m_project, m_sheets, m_unconnectedPins, makePicture(), TARGET3001::PAD::number, TARGET3001::ELEMENT::pad, path, TARGET3001::ELEMENT::pin, REFERENCE, SCH_SYMBOL::SetFootprintFieldText(), LIB_SYMBOL::SetGlobalPower(), LIB_SYMBOL::SetLibId(), SCH_SYMBOL::SetLibSymbol(), SCH_FIELD::SetPosition(), SCH_SYMBOL::SetRef(), SCH_FIELD::SetText(), LIB_SYMBOL::SetUnitCount(), EDA_TEXT::SetVisible(), sheetOf(), TARGET3001::ELEMENT::signal, TARGET3001::ELEMENT_BASE::signal, TARGET3001::PIN::supplyPin, TARGET3001::ELEMENT::symbol, TARGET3001::ELEMENT::text, toSch(), ToWx(), TARGET3001::ELEMENT::type, VALUE, UTF8::wx_str(), TARGET3001::ELEMENT_BASE::x, and TARGET3001::ELEMENT_BASE::y.
Referenced by Build().
|
private |
Definition at line 813 of file target3001_sch_builder.cpp.
References addNetItem(), addToSheet(), anchor, TARGET3001::ELEMENT::base, TARGET3001::ELEMENT::disc, TARGET3001::TEXT::function, joinsGlobally(), labelAnchor(), LAYER_BUS, LAYER_WIRE, TARGET3001::ELEMENT::line, m_fonts, m_globalSignals, makeGraphic(), name, TARGET3001::DISC::radius, SCH_LINE::SetEndPoint(), sheetOf(), TARGET3001::ELEMENT::signal, TARGET3001::ELEMENT_BASE::signal, TARGET3001::ELEMENT::text, toSch(), ToWx(), TARGET3001::ELEMENT::type, TARGET3001::ELEMENT_BASE::x, TARGET3001::LINE::x2, TARGET3001::ELEMENT_BASE::y, and TARGET3001::LINE::y2.
Referenced by Build().
|
private |
Definition at line 1635 of file target3001_sch_builder.cpp.
References addFreeSymbol(), addToSheet(), makeGraphic(), sheetOf(), TARGET3001::ELEMENT::symbol, and TARGET3001::ELEMENT::type.
Referenced by Build().
|
private |
Definition at line 1652 of file target3001_sch_builder.cpp.
References addGateBodies(), addToSheet(), TARGET3001::ELEMENT::base, LIB_ID::FixIllegalChars(), SCH_SYMBOL::GetField(), LIB_SYMBOL::GetLibId(), LIB_SYMBOL::GetReferenceField(), m_freeSymbolCount, m_sheets, makePicture(), path, REFERENCE, SCH_SYMBOL::SetExcludedFromBoard(), SCH_SYMBOL::SetExcludedFromBOM(), SCH_SYMBOL::SetExcludedFromSim(), LIB_SYMBOL::SetLibId(), SCH_SYMBOL::SetLibSymbol(), SCH_SYMBOL::SetRef(), SCH_FIELD::SetText(), EDA_TEXT::SetVisible(), sheetOf(), TARGET3001::ELEMENT::symbol, toSch(), VALUE, UTF8::wx_str(), TARGET3001::ELEMENT_BASE::x, and TARGET3001::ELEMENT_BASE::y.
Referenced by addFreeItem().
|
private |
Draw each gate's body as one unit of aLib; aFieldTexts leaves reference and value texts to fields.
Pins take the number of the package pad they connect to from aPadNumbers, keyed by pin number.
Definition at line 714 of file target3001_sch_builder.cpp.
References LIB_SYMBOL::AddDrawItem(), TARGET3001::ELEMENT::base, TARGET3001::ELEMENT::children, TARGET3001::PIN::direction, TARGET3001::ELEMENT_BASE::FindProp(), TARGET3001::TEXT::function, LIB_SYMBOL::GetDrawItems(), EDA_TEXT::GetTextHeight(), TARGET3001::PIN::length, m_fonts, makeGraphic(), name, pad, pin, TARGET3001::ELEMENT::pin, TARGET3001::PIN::pinNumber, SYMBOL::SetShowPinNames(), SYMBOL::SetShowPinNumbers(), TARGET3001::PIN::showNumber, MULTIVECTOR< T, FIRST_TYPE_VAL, LAST_TYPE_VAL >::sort(), TARGET3001::ELEMENT::symbol, TARGET3001::ELEMENT::text, TARGET3001::TEXT::text, toSch(), ToWx(), TARGET3001::ELEMENT::type, TARGET3001::ELEMENT_BASE::x, and TARGET3001::ELEMENT_BASE::y.
Referenced by addComponent(), and addFreeSymbol().
|
private |
Add a wire, junction or label of signal aSignal; separateSignals() keeps it apart from other signals.
Definition at line 1246 of file target3001_sch_builder.cpp.
References addToSheet(), and m_netItems.
Referenced by addConnections(), bendAround(), joinPieces(), and separateSignals().
|
private |
Definition at line 363 of file target3001_sch_builder.cpp.
References EDA_ITEM::GetBoundingBox(), m_extents, m_pending, and BOX2< Vec >::Merge().
Referenced by addComponent(), addConnections(), addFreeItem(), addFreeSymbol(), and addNetItem().
|
private |
Bend the wires of aSignal that pass through aPos around it, one gap aside on a side aIsFree accepts, adding the new pieces to aWires.
Returns the offset of the bent run at aPos, or nothing when the wires are too short or not parallel.
Definition at line 1570 of file target3001_sch_builder.cpp.
References addNetItem(), VECTOR2< T >::Cross(), end, normal, VECTOR2< T >::Resize(), SCH_LINE::SetEndPoint(), SCH_LINE::SetStartPoint(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by separateSignals().
| void TARGET3001_SCH_BUILDER::Build | ( | ) |
Definition at line 304 of file target3001_sch_builder.cpp.
References addComponent(), addConnections(), addFreeItem(), TARGET3001::ELEMENT::component, finishSheets(), joinSignalPieces(), m_netItems, m_project, screen(), separateSignals(), sheetOf(), TARGET3001::ELEMENT::signal, and TARGET3001::ELEMENT::type.
Referenced by SCH_IO_TARGET3001::LoadSchematicFile().
|
private |
Definition at line 1728 of file target3001_sch_builder.cpp.
References SCH_SCREEN::Append(), BOX2< Vec >::GetHeight(), BOX2< Vec >::GetLeft(), BOX2< Vec >::GetTop(), BOX2< Vec >::GetWidth(), KiROUND(), m_extents, m_pending, m_schematic, m_sheets, schIUScale, screen(), PAGE_INFO::SetHeightMM(), SCH_SCREEN::SetPageSettings(), PAGE_INFO::SetWidthMM(), and User.
Referenced by Build().
|
private |
Join the pieces of signal aSignal that KiCad would see apart, since the file joins a signal's items by identity.
aItems holds the signal's net items by sheet. Ends a hair apart get a stub wire, and each piece holding a pin but no name gets a label.
< open wire ends and their outward direction
Definition at line 979 of file target3001_sch_builder.cpp.
References addNetItem(), SPIN_STYLE::BOTTOM, end, find, SCH_LINE::GetEndPoint(), EDA_ITEM::GetPosition(), SCH_LINE::GetStartPoint(), index, IsPointOnSegment(), LAYER_WIRE, SPIN_STYLE::LEFT, m_globalSignals, m_netItems, m_pinEnds, m_pinSignals, m_project, name, pin, PIN_DOWN, PIN_RIGHT, PIN_UP, SPIN_STYLE::RIGHT, SCH_LINE_T, SCH_LINE::SetEndPoint(), SCH_LABEL_BASE::SetSpinStyle(), TARGET3001::ELEMENT::signal, ToWx(), EDA_ITEM::Type(), TARGET3001::ELEMENT::type, and SPIN_STYLE::UP.
Referenced by joinSignalPieces().
|
private |
True when the signal's labels must be global: it reaches several sheets or meets supply symbols.
Definition at line 888 of file target3001_sch_builder.cpp.
References TARGET3001::ELEMENT::base, m_pinEnds, m_powerSheets, pin, sheetOf(), TARGET3001::ELEMENT::signal, and TARGET3001::ELEMENT_BASE::signal.
Referenced by addConnections().
|
private |
Join the pieces of every signal as separateSignals() left them; see joinPieces()
Definition at line 961 of file target3001_sch_builder.cpp.
References joinPieces(), m_netItems, and m_pinEnds.
Referenced by Build().
|
private |
Point on the signal's own wires or pins nearest a name drawn at aPos, if it is close enough to name them.
Definition at line 915 of file target3001_sch_builder.cpp.
References SEG::A, SEG::B, TARGET3001::ELEMENT::base, TARGET3001::ELEMENT::line, m_pinEnds, SEG::NearestPoint(), pin, sheetOf(), TARGET3001::ELEMENT::signal, TARGET3001::ELEMENT_BASE::signal, SEG::Square(), toSch(), TARGET3001::ELEMENT::type, TARGET3001::ELEMENT_BASE::x, TARGET3001::LINE::x2, TARGET3001::ELEMENT_BASE::y, and TARGET3001::LINE::y2.
Referenced by addConnections().
|
private |
Add graphics shared by free items and symbol bodies; returns nullptr for unsupported items.
Definition at line 380 of file target3001_sch_builder.cpp.
References SCH_SHAPE::AddPoint(), ARC, TARGET3001::ELEMENT::arc, TARGET3001::ELEMENT::base, TARGET3001::FONTS::BaselineShift(), center, TARGET3001::ARC::centerX, TARGET3001::ARC::centerY, CIRCLE, TARGET3001::LINE::dashStyle, DEG2RAD(), DEGREES_T, TARGET3001::RECTANGLE::direction, TARGET3001::ELEMENT::disc, FILLED_SHAPE, TARGET3001::RECTANGLE::height, KiROUND(), LAYER_DEVICE, LAYER_NOTES, TARGET3001::ELEMENT::line, m_fonts, m_project, makePicture(), POLY, radius, TARGET3001::ARC::radius, TARGET3001::DISC::radius, TARGET3001::ELEMENT::rectangle, RotatePoint(), EDA_SHAPE::SetArcGeometry(), EDA_SHAPE::SetCenter(), EDA_SHAPE::SetEnd(), SCH_LINE::SetEndPoint(), SCH_LINE::SetStroke(), SCH_SHAPE::SetStroke(), TARGET3001::ARC::startAngle, TARGET3001::ARC::Sweep(), sweep(), text, TARGET3001::ELEMENT::text, TARGET3001::TEXT::text, toSch(), ToWx(), TARGET3001::ELEMENT::triangle, TARGET3001::ELEMENT::type, TARGET3001::ARC::width, TARGET3001::LINE::width, TARGET3001::RECTANGLE::width, TARGET3001::ELEMENT_BASE::x, VECTOR2< T >::x, TARGET3001::LINE::x2, TARGET3001::TRIANGLE::x2, TARGET3001::TRIANGLE::x3, TARGET3001::ELEMENT_BASE::y, VECTOR2< T >::y, TARGET3001::LINE::y2, TARGET3001::TRIANGLE::y2, and TARGET3001::TRIANGLE::y3.
Referenced by addConnections(), addFreeItem(), and addGateBodies().
|
private |
Image a rectangle shows instead of its fill, or nullptr when it has none.
Definition at line 497 of file target3001_sch_builder.cpp.
References std::abs(), TARGET3001::ELEMENT::base, center, DEGREES_T, TARGET3001::RECTANGLE::direction, SCH_BITMAP::GetReferenceImage(), TARGET3001::RECTANGLE::height, image, EDA_ANGLE::IsZero(), KiROUND(), REFERENCE_IMAGE::MutableImage(), TARGET3001::ELEMENT_BASE::Picture(), TARGET3001::ELEMENT::rectangle, REFERENCE_IMAGE::Rotate(), RotatePoint(), REFERENCE_IMAGE::SetImage(), BITMAP_BASE::SetImageType(), REFERENCE_IMAGE::SetPosition(), REFERENCE_IMAGE::SetWidth(), toSch(), TARGET3001::ELEMENT::type, TARGET3001::RECTANGLE::width, TARGET3001::ELEMENT_BASE::x, VECTOR2< T >::x, TARGET3001::ELEMENT_BASE::y, and VECTOR2< T >::y.
Referenced by addComponent(), addFreeSymbol(), and makeGraphic().
|
private |
Screen for a 1-based sheet number, created on first use.
Definition at line 1684 of file target3001_sch_builder.cpp.
References SCH_SHEET::GetScreen(), FILEEXT::KiCadSchematicFileExtension, m_fileName, m_project, m_rootSheet, m_schematic, m_sheets, name, SCH_SCREEN::SetFileName(), SCH_SHEET::SetFileName(), SCH_SHEET::SetName(), SCH_SHEET::SetScreen(), and ToWx().
Referenced by Build(), and finishSheets().
|
private |
Move apart items of different signals that touch where KiCad would join them, since the file connects items by signal alone.
Wire ends also leave buses, taking a label so the bus still joins its members.
Definition at line 1253 of file target3001_sch_builder.cpp.
References addNetItem(), bendAround(), end, SCH_LINE::GetEndPoint(), SCH_LINE::GetLength(), SCH_LINE::GetStartPoint(), group, IsPointOnSegment(), m_globalSignals, m_netItems, m_pinSignals, m_project, moved, name, VECTOR2< T >::Resize(), SCH_LINE_T, SCH_LINE::SetEndPoint(), SCH_LABEL_BASE::SetSpinStyle(), SCH_LINE::SetStartPoint(), TARGET3001::ELEMENT::signal, ToWx(), VECTOR2< T >::x, and VECTOR2< T >::y.
Referenced by Build().
|
staticprivate |
Sheet number of a schematic element, or 0 for board elements.
Definition at line 293 of file target3001_sch_builder.cpp.
References TARGET3001::ELEMENT::base, TARGET3001::ELEMENT_BASE::layer, TARGET3001::SCHEMATIC_LAYER_BASE, and TARGET3001::SCHEMATIC_SHEET_COUNT.
Referenced by addComponent(), addConnections(), addFreeItem(), addFreeSymbol(), Build(), joinsGlobally(), and labelAnchor().
|
staticprivate |
Definition at line 287 of file target3001_sch_builder.cpp.
References KiROUND().
|
staticprivate |
Sheet position in KiCad units, before the per-sheet page offset is applied.
Definition at line 281 of file target3001_sch_builder.cpp.
References KiROUND().
Referenced by addComponent(), addConnections(), addFreeSymbol(), addGateBodies(), labelAnchor(), makeGraphic(), and makePicture().
|
private |
drawn extent of each sheet
Definition at line 145 of file target3001_sch_builder.h.
Referenced by addToSheet(), and finishSheets().
|
private |
Definition at line 141 of file target3001_sch_builder.h.
Referenced by screen(), and TARGET3001_SCH_BUILDER().
|
mutableprivate |
lookup cache, filled while drawing
Definition at line 155 of file target3001_sch_builder.h.
Referenced by addComponent(), addConnections(), addGateBodies(), and makeGraphic().
|
private |
Definition at line 148 of file target3001_sch_builder.h.
Referenced by addFreeSymbol().
|
private |
signals joined by global labels
Definition at line 152 of file target3001_sch_builder.h.
Referenced by addConnections(), joinPieces(), and separateSignals().
|
private |
items and their signal, by sheet
Definition at line 150 of file target3001_sch_builder.h.
Referenced by addNetItem(), Build(), joinPieces(), joinSignalPieces(), and separateSignals().
|
private |
Definition at line 146 of file target3001_sch_builder.h.
Referenced by addToSheet(), and finishSheets().
|
private |
placed pins of each signal, by signal ID
Definition at line 153 of file target3001_sch_builder.h.
Referenced by addComponent(), joinPieces(), joinsGlobally(), joinSignalPieces(), and labelAnchor().
|
private |
pin points and signal, by sheet
Definition at line 151 of file target3001_sch_builder.h.
Referenced by addComponent(), joinPieces(), and separateSignals().
|
private |
Definition at line 147 of file target3001_sch_builder.h.
Referenced by addComponent().
|
private |
sheets holding a power symbol, by signal ID
Definition at line 149 of file target3001_sch_builder.h.
Referenced by addComponent(), and joinsGlobally().
|
private |
Definition at line 140 of file target3001_sch_builder.h.
Referenced by addComponent(), Build(), joinPieces(), makeGraphic(), screen(), separateSignals(), and TARGET3001_SCH_BUILDER().
|
private |
Definition at line 142 of file target3001_sch_builder.h.
Referenced by TARGET3001_SCH_BUILDER().
|
private |
Definition at line 139 of file target3001_sch_builder.h.
Referenced by screen(), and TARGET3001_SCH_BUILDER().
|
private |
Definition at line 138 of file target3001_sch_builder.h.
Referenced by finishSheets(), screen(), and TARGET3001_SCH_BUILDER().
|
private |
by 1-based sheet number
Definition at line 144 of file target3001_sch_builder.h.
Referenced by addComponent(), addFreeSymbol(), finishSheets(), and screen().
|
private |
Definition at line 154 of file target3001_sch_builder.h.
Referenced by addComponent().