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

#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
 

Detailed Description

Definition at line 54 of file target3001_sch_builder.h.

Constructor & Destructor Documentation

◆ TARGET3001_SCH_BUILDER()

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.

Member Function Documentation

◆ addComponent()

◆ addConnections()

◆ addFreeItem()

void TARGET3001_SCH_BUILDER::addFreeItem ( const TARGET3001::ELEMENT & aElem)
private

◆ addFreeSymbol()

◆ addGateBodies()

void TARGET3001_SCH_BUILDER::addGateBodies ( LIB_SYMBOL * aLib,
const std::vector< const TARGET3001::ELEMENT * > & aGates,
bool aFieldTexts,
const std::map< uint16_t, wxString > & aPadNumbers = {} ) const
private

◆ addNetItem()

void TARGET3001_SCH_BUILDER::addNetItem ( int aSheet,
SCH_ITEM * aItem,
int aSignal )
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().

◆ addToSheet()

void TARGET3001_SCH_BUILDER::addToSheet ( int aSheet,
SCH_ITEM * aItem )
private

◆ bendAround()

std::optional< VECTOR2I > TARGET3001_SCH_BUILDER::bendAround ( int aSheet,
int aSignal,
const VECTOR2I & aPos,
std::vector< std::pair< SCH_LINE *, int > > & aWires,
const std::function< bool(const VECTOR2I &)> & aIsFree )
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().

◆ Build()

◆ finishSheets()

◆ joinPieces()

void TARGET3001_SCH_BUILDER::joinPieces ( int aSignal,
const std::map< int, std::vector< SCH_ITEM * > > & aItems )
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().

◆ joinsGlobally()

bool TARGET3001_SCH_BUILDER::joinsGlobally ( const TARGET3001::ELEMENT & aSignal) const
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().

◆ joinSignalPieces()

void TARGET3001_SCH_BUILDER::joinSignalPieces ( )
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().

◆ labelAnchor()

std::optional< VECTOR2I > TARGET3001_SCH_BUILDER::labelAnchor ( const TARGET3001::ELEMENT & aSignal,
int aSheet,
const VECTOR2I & aPos ) const
private

◆ makeGraphic()

SCH_ITEM * TARGET3001_SCH_BUILDER::makeGraphic ( const TARGET3001::ELEMENT & aElem,
const VECTOR2I & aOrigin,
bool aInSymbol ) const
private

◆ makePicture()

◆ screen()

SCH_SCREEN * TARGET3001_SCH_BUILDER::screen ( int aSheet)
private

◆ separateSignals()

void TARGET3001_SCH_BUILDER::separateSignals ( int aSheet)
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().

◆ sheetOf()

int TARGET3001_SCH_BUILDER::sheetOf ( const TARGET3001::ELEMENT & aElem)
staticprivate

◆ toSch() [1/2]

int TARGET3001_SCH_BUILDER::toSch ( int32_t aLength)
staticprivate

Definition at line 287 of file target3001_sch_builder.cpp.

References KiROUND().

◆ toSch() [2/2]

VECTOR2I TARGET3001_SCH_BUILDER::toSch ( int32_t aX,
int32_t aY )
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().

Member Data Documentation

◆ m_extents

std::map<int, BOX2I> TARGET3001_SCH_BUILDER::m_extents
private

drawn extent of each sheet

Definition at line 145 of file target3001_sch_builder.h.

Referenced by addToSheet(), and finishSheets().

◆ m_fileName

wxString TARGET3001_SCH_BUILDER::m_fileName
private

Definition at line 141 of file target3001_sch_builder.h.

Referenced by screen(), and TARGET3001_SCH_BUILDER().

◆ m_fonts

TARGET3001::FONTS TARGET3001_SCH_BUILDER::m_fonts
mutableprivate

lookup cache, filled while drawing

Definition at line 155 of file target3001_sch_builder.h.

Referenced by addComponent(), addConnections(), addGateBodies(), and makeGraphic().

◆ m_freeSymbolCount

int TARGET3001_SCH_BUILDER::m_freeSymbolCount = 0
private

Definition at line 148 of file target3001_sch_builder.h.

Referenced by addFreeSymbol().

◆ m_globalSignals

std::set<int> TARGET3001_SCH_BUILDER::m_globalSignals
private

signals joined by global labels

Definition at line 152 of file target3001_sch_builder.h.

Referenced by addConnections(), joinPieces(), and separateSignals().

◆ m_netItems

std::map<int, std::vector<std::pair<SCH_ITEM*, int> > > TARGET3001_SCH_BUILDER::m_netItems
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().

◆ m_pending

std::map<int, std::vector<SCH_ITEM*> > TARGET3001_SCH_BUILDER::m_pending
private

Definition at line 146 of file target3001_sch_builder.h.

Referenced by addToSheet(), and finishSheets().

◆ m_pinEnds

std::map<int, std::vector<PIN_END> > TARGET3001_SCH_BUILDER::m_pinEnds
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().

◆ m_pinSignals

std::map<int, std::vector<std::pair<VECTOR2I, int> > > TARGET3001_SCH_BUILDER::m_pinSignals
private

pin points and signal, by sheet

Definition at line 151 of file target3001_sch_builder.h.

Referenced by addComponent(), joinPieces(), and separateSignals().

◆ m_powerCount

int TARGET3001_SCH_BUILDER::m_powerCount = 0
private

Definition at line 147 of file target3001_sch_builder.h.

Referenced by addComponent().

◆ m_powerSheets

std::map<int, std::set<int> > TARGET3001_SCH_BUILDER::m_powerSheets
private

sheets holding a power symbol, by signal ID

Definition at line 149 of file target3001_sch_builder.h.

Referenced by addComponent(), and joinsGlobally().

◆ m_project

const TARGET3001::PROJECT& TARGET3001_SCH_BUILDER::m_project
private

◆ m_reporter

REPORTER* TARGET3001_SCH_BUILDER::m_reporter
private

Definition at line 142 of file target3001_sch_builder.h.

Referenced by TARGET3001_SCH_BUILDER().

◆ m_rootSheet

SCH_SHEET* TARGET3001_SCH_BUILDER::m_rootSheet
private

Definition at line 139 of file target3001_sch_builder.h.

Referenced by screen(), and TARGET3001_SCH_BUILDER().

◆ m_schematic

SCHEMATIC* TARGET3001_SCH_BUILDER::m_schematic
private

Definition at line 138 of file target3001_sch_builder.h.

Referenced by finishSheets(), screen(), and TARGET3001_SCH_BUILDER().

◆ m_sheets

std::map<int, SCH_SHEET*> TARGET3001_SCH_BUILDER::m_sheets
private

by 1-based sheet number

Definition at line 144 of file target3001_sch_builder.h.

Referenced by addComponent(), addFreeSymbol(), finishSheets(), and screen().

◆ m_unconnectedPins

int TARGET3001_SCH_BUILDER::m_unconnectedPins = 0
private

Definition at line 154 of file target3001_sch_builder.h.

Referenced by addComponent().


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