42#include <shared_mutex>
72#define DEFAULT_CHAINING_EPSILON_MM 0.01
85 return A == other.
A &&
B == other.
B;
119 std::size_t seed = 0xa82de1c0;
130 std::size_t seed = 0xa82de1c0;
141 std::size_t seed = 0xa82de1c0;
265 std::vector<BOARD_ITEM*>& aRemovedItems,
266 std::vector<BOARD_ITEM*>& aDeletedItems )
401 bool aSkipConnectivity =
false )
override;
439 const std::vector<ZONE*>& aZones = {} );
463 void FillItemMap( std::map<KIID, EDA_ITEM*>& aMap );
489 void DeleteMARKERs(
bool aWarningsAndErrors,
bool aExclusions );
729 bool aAllowUseArcsInPolygons =
false,
730 bool aIncludeNPTHAsOutlines =
false );
832 const std::vector<PAD*>
GetPads()
const;
864 int MatchDpSuffix(
const wxString& aNetName, wxString& aComplementNet );
948 const std::vector<KICAD_T>& scanTypes )
override;
999 return wxT(
"BOARD" );
1003 void Show(
int nestLevel, std::ostream& os )
const override { ShowDummy( os ); }
1030 if( (
unsigned) index <
m_zones.size() )
1039 std::list<ZONE*>
GetZoneList(
bool aIncludeZonesInFootprints =
false )
const;
1046 return static_cast<int>(
m_zones.size() );
1168 bool aVisibleOnly,
bool aIgnoreLocked =
false )
const;
1224 std::vector<BOARD_ITEM*>& aRemovedItems,
1225 std::vector<BOARD_ITEM*>& aChangedItems );
1318 template <
typename Func,
typename... Args>
1322 ( l->*aFunc )( std::forward<Args>( args )... );
BOARD_USE
Flags to specify how the board is being used.
LAYER_T
The allowed types of layers, same as Specctra DSN spec.
std::set< BOARD_ITEM *, CompareByUuid > BOARD_ITEM_SET
Set of BOARD_ITEMs ordered by UUID.
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Container for design settings for a BOARD object.
Abstract interface for BOARD_ITEMs capable of storing other items inside.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
wxString GetLayerName() const
Return the name of the PCB layer on which the item resides.
virtual void OnBoardNetSettingsChanged(BOARD &aBoard)
virtual void OnBoardItemsAdded(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
virtual void OnBoardRatsnestChanged(BOARD &aBoard)
virtual void OnBoardCompositeUpdate(BOARD &aBoard, std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aDeletedItems)
virtual void OnBoardItemsChanged(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
virtual void OnBoardItemChanged(BOARD &aBoard, BOARD_ITEM *aBoardItem)
virtual void OnBoardItemRemoved(BOARD &aBoard, BOARD_ITEM *aBoardItem)
virtual void OnBoardItemAdded(BOARD &aBoard, BOARD_ITEM *aBoardItem)
virtual void OnBoardHighlightNetChanged(BOARD &aBoard)
virtual ~BOARD_LISTENER()
virtual void OnBoardItemsRemoved(BOARD &aBoard, std::vector< BOARD_ITEM * > &aBoardItem)
Manage layers needed to make a physical board.
Information pertinent to a Pcbnew printed circuit board.
INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &scanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
ZONE * m_SolderMaskBridges
void GetContextualTextVars(wxArrayString *aVars) const
bool IsFootprintLayerVisible(PCB_LAYER_ID aLayer) const
Expect either of the two layers on which a footprint can reside, and returns whether that layer is vi...
BOARD_STACKUP GetStackupOrDefault() const
void SetPlotOptions(const PCB_PLOT_PARAMS &aOptions)
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_EnclosedByAreaCache
std::map< ZONE *, std::map< PCB_LAYER_ID, ISOLATED_ISLANDS > > m_ZoneIsolatedIslandsMap
PCB_LAYER_ID GetCopperLayerStackMaxId() const
bool GetBoardPolygonOutlines(SHAPE_POLY_SET &aOutlines, OUTLINE_ERROR_HANDLER *aErrorHandler=nullptr, bool aAllowUseArcsInPolygons=false, bool aIncludeNPTHAsOutlines=false)
Extract the board outlines and build a closed polygon from lines, arcs and circle items on edge cut l...
void OnItemChanged(BOARD_ITEM *aItem)
Notify the board and its listeners that an item on the board has been modified in some way.
const NETINFO_LIST & GetNetInfo() const
bool m_LegacyDesignSettingsLoaded
True if the legacy board design settings were loaded from a file.
bool IsFootprintHolder() const
Find out if the board is being used to hold a single footprint for editing/viewing.
LSET GetEnabledLayers() const
A proxy function that calls the corresponding function in m_BoardSettings.
void SetPosition(const VECTOR2I &aPos) override
std::map< wxString, wxString > m_properties
EMBEDDED_FILES * GetEmbeddedFiles() override
int m_fileFormatVersionAtLoad
NETINFO_ITEM * DpCoupledNet(const NETINFO_ITEM *aNet)
LSET GetVisibleLayers() const
A proxy function that calls the correspondent function in m_BoardSettings.
std::vector< ZONE * > m_DRCCopperZones
BOARD_USE GetBoardUse() const
Get what the board use is.
void Add(BOARD_ITEM *aItem, ADD_MODE aMode=ADD_MODE::INSERT, bool aSkipConnectivity=false) override
Removes an item from the container.
const std::set< int > & GetHighLightNetCodes() const
void MapNets(BOARD *aDestBoard)
Map all nets in the given board to nets with the same name (if any) in the destination board.
bool m_legacyTeardrops
Teardrops in 7.0 were applied as a post-processing step (rather than from pad and via properties).
GAL_SET m_LegacyVisibleItems
void SetBoardUse(BOARD_USE aUse)
Set what the board is going to be used for.
ZONE * GetArea(int index) const
Return the Zone at a given index.
const BOX2I GetBoardEdgesBoundingBox() const
Return the board bounding box calculated using exclusively the board edges (graphics on Edge....
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
PAD * GetPadFast(const VECTOR2I &aPosition, LSET aLayerMask) const
Return pad found at aPosition on aLayerMask using the fast search method.
const GENERATORS & Generators() const
void SetFileName(const wxString &aFileName)
static wxString GetStandardLayerName(PCB_LAYER_ID aLayerId)
Return an "English Standard" name of a PCB layer when given aLayerNumber.
const std::vector< BOARD_CONNECTED_ITEM * > AllConnectedItems()
bool IsElementVisible(GAL_LAYER_ID aLayer) const
Test whether a given element category is visible.
int m_outlinesChainingEpsilon
the max distance between 2 end point to see them connected when building the board outlines
std::set< wxString > GetNetClassAssignmentCandidates() const
Return the set of netname candidates for netclass assignment.
BOARD_USE m_boardUse
What is this board being used for.
void RemoveAllListeners()
Remove all listeners.
std::unique_ptr< BOARD_DESIGN_SETTINGS > m_designSettings
All of the board design settings are stored as a JSON object inside the project file.
void SetEnabledLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings.
void AddListener(BOARD_LISTENER *aListener)
Add a listener to the board to receive calls whenever something on the board has been modified.
const PAGE_INFO & GetPageSettings() const
void UpdateUserUnits(BOARD_ITEM *aItem, KIGFX::VIEW *aView)
Update any references within aItem (or its descendants) to the user units.
void SetProperties(const std::map< wxString, wxString > &aProps)
BOARD(const BOARD &aOther)=delete
GAL_SET GetVisibleElements() const
Return a set of all the element categories that are visible.
void SetHighLightNet(int aNetCode, bool aMulti=false)
Select the netcode to be highlighted.
HIGH_LIGHT_INFO m_highLight
bool SetLayerDescr(PCB_LAYER_ID aIndex, const LAYER &aLayer)
Return the type of the copper layer given by aLayer.
NETINFO_ITEM * FindNet(int aNetcode) const
Search for a net with the given netcode.
BOARD_ITEM * GetItem(const KIID &aID) const
const ZONES & Zones() const
void InvokeListeners(Func &&aFunc, Args &&... args)
ZONE * AddArea(PICKED_ITEMS_LIST *aNewZonesList, int aNetcode, PCB_LAYER_ID aLayer, VECTOR2I aStartPointPosition, ZONE_BORDER_DISPLAY_STYLE aHatch)
Add an empty copper area to board areas list.
const GROUPS & Groups() const
The groups must maintain the following invariants.
bool BuildConnectivity(PROGRESS_REPORTER *aReporter=nullptr)
Build or rebuild the board connectivity database for the board, especially the list of connected item...
bool IsLayerEnabled(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
LAYER_T GetLayerType(PCB_LAYER_ID aLayer) const
Return the type of the copper layer given by aLayer.
void RecordDRCExclusions()
Scan existing markers and record data from any that are Excluded.
void OnItemsCompositeUpdate(std::vector< BOARD_ITEM * > &aAddedItems, std::vector< BOARD_ITEM * > &aRemovedItems, std::vector< BOARD_ITEM * > &aChangedItems)
Notify the board and its listeners that items on the board have been modified in a composite operatio...
int SetAreasNetCodesFromNetNames()
Set the .m_NetCode member of all copper areas, according to the area Net Name The SetNetCodesFromNetN...
void SynchronizeNetsAndNetClasses(bool aResetTrackAndViaSizes)
Copy NETCLASS info to each NET, based on NET membership in a NETCLASS.
void ResetNetHighLight()
Reset all high light data to the init state.
PCB_PLOT_PARAMS m_plotOptions
bool SetLayerName(PCB_LAYER_ID aLayer, const wxString &aLayerName)
Changes the name of the layer given by aLayer.
std::list< ZONE * > GetZoneList(bool aIncludeZonesInFootprints=false) const
void ConvertBrdLayerToPolygonalContours(PCB_LAYER_ID aLayer, SHAPE_POLY_SET &aOutlines) const
Build a set of polygons which are the outlines of copper items (pads, tracks, vias,...
bool ResolveTextVar(wxString *token, int aDepth) const
const MARKERS & Markers() const
FOOTPRINT * GetFirstFootprint() const
Get the first footprint on the board or nullptr.
PCB_LAYER_ID FlipLayer(PCB_LAYER_ID aLayer) const
const std::vector< PAD * > GetPads() const
Return a reference to a list of all the pads.
void Move(const VECTOR2I &aMoveVector) override
Move this object.
TITLE_BLOCK & GetTitleBlock()
BOX2I ComputeBoundingBox(bool aBoardEdgesOnly=false) const
Calculate the bounding box containing all board items (or board edge segments).
void FixupEmbeddedData()
After loading a file from disk, the footprints do not yet contain the full data for their embedded fi...
int GetMaxClearanceValue() const
Returns the maximum clearance value for any object on the board.
PAD * GetPad(const VECTOR2I &aPosition) const
PCB_LAYER_ID GetLayerID(const wxString &aLayerName) const
Return the ID of a layer.
HIGH_LIGHT_INFO m_highLightPrevious
const VECTOR2I GetFocusPosition() const override
Similar to GetPosition, but allows items to return their visual center rather than their anchor.
void HighLightOFF()
Disable net highlight.
LSET m_LegacyVisibleLayers
Visibility settings stored in board prior to 6.0, only used for loading legacy files.
void SetVisibleAlls()
Change the bit-mask of visible element categories and layers.
void SetOutlinesChainingEpsilon(int aValue)
NETINFO_LIST::iterator EndNets() const
GroupLegalOpsField GroupLegalOps(const PCB_SELECTION &selection) const
Check which selection tool group operations are legal given the selection.
int GetCopperLayerCount() const
std::vector< BOARD_LISTENER * > m_listeners
const std::map< wxString, wxString > & GetProperties() const
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsCourtyardCache
void IncrementTimeStamp()
int MatchDpSuffix(const wxString &aNetName, wxString &aComplementNet)
Fetch the coupled netname for a given net.
COMPONENT_CLASS_MANAGER m_componentClassManager
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsFCourtyardCache
void RemoveUnusedNets(BOARD_COMMIT *aCommit)
const FOOTPRINTS & Footprints() const
std::shared_ptr< CONNECTIVITY_DATA > m_connectivity
void RemoveAll(std::initializer_list< KICAD_T > aTypes={ PCB_NETINFO_T, PCB_MARKER_T, PCB_GROUP_T, PCB_ZONE_T, PCB_GENERATOR_T, PCB_FOOTPRINT_T, PCB_TRACE_T, PCB_SHAPE_T })
An efficient way to remove all items of a certain type from the board.
const BOARD_ITEM_SET GetItemSet()
const TRACKS & Tracks() const
int m_DRCMaxPhysicalClearance
FOOTPRINT * FindFootprintByPath(const KIID_PATH &aPath) const
Search for a FOOTPRINT within this board with the given path.
void FinalizeBulkRemove(std::vector< BOARD_ITEM * > &aRemovedItems)
Must be used if Remove() is used using a BULK_x REMOVE_MODE to generate a change event for listeners.
void SetPageSettings(const PAGE_INFO &aPageSettings)
std::unordered_map< wxString, LSET > m_LayerExpressionCache
wxString GroupsSanityCheckInternal(bool repair)
void OnRatsnestChanged()
Notify the board and its listeners that the ratsnest has been recomputed.
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
wxString GetClass() const override
Return the class name.
void SetVisibleLayers(LSET aLayerMask)
A proxy function that calls the correspondent function in m_BoardSettings changes the bit-mask of vis...
NETINFO_LIST::iterator BeginNets() const
bool m_LegacyNetclassesLoaded
True if netclasses were loaded from the file.
void SetCopperLayerCount(int aCount)
std::unordered_map< const ZONE *, BOX2I > m_ZoneBBoxCache
std::unordered_map< PTR_PTR_CACHE_KEY, bool > m_IntersectsBCourtyardCache
TRACKS TracksInNet(int aNetCode)
Collect all the TRACKs and VIAs that are members of a net given by aNetCode.
void SetProject(PROJECT *aProject, bool aReferenceOnly=false)
Link a board to a given project.
FOOTPRINT * GetFootprint(const VECTOR2I &aPosition, PCB_LAYER_ID aActiveLayer, bool aVisibleOnly, bool aIgnoreLocked=false) const
Get a footprint by its bounding rectangle at aPosition on aLayer.
const wxString & GetFileName() const
bool operator==(const BOARD_ITEM &aOther) const override
std::vector< PCB_MARKER * > ResolveDRCExclusions(bool aCreateMarkers)
Rebuild DRC markers from the serialized data in BOARD_DESIGN_SETTINGS.
FOOTPRINT * FindFootprintByReference(const wxString &aReference) const
Search for a FOOTPRINT within this board with the given reference designator.
unsigned GetNodesCount(int aNet=-1) const
bool IsHighLightNetON() const
void FillItemMap(std::map< KIID, EDA_ITEM * > &aMap)
int GetFileFormatVersionAtLoad() const
void SetElementVisibility(GAL_LAYER_ID aLayer, bool aNewState)
Change the visibility of an element category.
std::shared_ptr< DRC_RTREE > m_CopperItemRTreeCache
bool SetLayerType(PCB_LAYER_ID aLayer, LAYER_T aLayerType)
Change the type of the layer given by aLayer.
const PCB_PLOT_PARAMS & GetPlotOptions() const
BOARD & operator=(const BOARD &aOther)=delete
const wxString & GetGenerator() const
Adds an item to the container.
void SetLegacyTeardrops(bool aFlag)
std::map< int, LAYER > m_layers
int GetOutlinesChainingEpsilon()
void GetSortedPadListByXthenYCoord(std::vector< PAD * > &aVector, int aNetCode=-1) const
First empties then fills the vector with all pads and sorts them by increasing x coordinate,...
bool IsLayerVisible(PCB_LAYER_ID aLayer) const
A proxy function that calls the correspondent function in m_BoardSettings tests whether a given layer...
std::unordered_map< ZONE *, std::unique_ptr< DRC_RTREE > > m_CopperZoneRTreeCache
void FinalizeBulkAdd(std::vector< BOARD_ITEM * > &aNewItems)
Must be used if Add() is used using a BULK_x ADD_MODE to generate a change event for listeners.
int LayerDepth(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer) const
void DeleteAllFootprints()
Remove all footprints from the deque and free the memory associated with them.
PROJECT * GetProject() const
bool LegacyTeardrops() const
std::tuple< int, double, double > GetTrackLength(const PCB_TRACK &aTrack) const
Return data on the length and number of track segments connected to a given track.
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
const TITLE_BLOCK & GetTitleBlock() const
wxString GroupsSanityCheck(bool repair=false)
Consistency check of internal m_groups structure.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
std::vector< ZONE * > m_DRCZones
PAD * GetPad(const VECTOR2I &aPosition, LSET aLayerMask) const
Find a pad aPosition on aLayer.
void SetGenerator(const wxString &aGenerator)
void UpdateRatsnestExclusions()
Update the visibility flags on the current unconnected ratsnest lines.
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
void SynchronizeProperties()
Copy the current project's text variables into the boards property cache.
std::unordered_map< KIID, BOARD_ITEM * > m_itemByIdCache
void RemoveListener(BOARD_LISTENER *aListener)
Remove the specified listener.
COMPONENT_CLASS_MANAGER & GetComponentClassManager()
Gets the component class manager.
std::shared_mutex m_CachesMutex
unsigned GetNetCount() const
void DeleteMARKERs()
Delete all MARKERS from the board.
void Remove(BOARD_ITEM *aBoardItem, REMOVE_MODE aMode=REMOVE_MODE::NORMAL) override
Removes an item from the container.
std::unordered_map< PTR_PTR_LAYER_CACHE_KEY, bool > m_IntersectsAreaCache
std::optional< int > m_maxClearanceValue
void HighLightON(bool aValue=true)
Enable or disable net highlighting.
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
bool TestZoneIntersection(ZONE *aZone1, ZONE *aZone2)
Test for intersection of 2 copper areas.
bool m_LegacyCopperEdgeClearanceLoaded
void OnItemsChanged(std::vector< BOARD_ITEM * > &aItems)
Notify the board and its listeners that an item on the board has been modified in some way.
std::shared_ptr< CONNECTIVITY_DATA > GetConnectivity() const
Return a list of missing connections between components/tracks.
VECTOR2I GetPosition() const override
void CacheTriangulation(PROGRESS_REPORTER *aReporter=nullptr, const std::vector< ZONE * > &aZones={})
static bool ClassOf(const EDA_ITEM *aItem)
void SetUserUnits(EDA_UNITS aUnits)
void SetVisibleElements(const GAL_SET &aMask)
A proxy function that calls the correspondent function in m_BoardSettings.
void EmbedFonts() override
Finds all fonts used in the board and embeds them in the file if permissions allow.
double Similarity(const BOARD_ITEM &aOther) const override
Return the Similarity.
const DRAWINGS & Drawings() const
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
void SetFileFormatVersionAtLoad(int aVersion)
constexpr const Vec GetCenter() const
Store all of the related footprint information found in a netlist.
Implement an R-tree for fast spatial and layer indexing of connectable items.
The base class for create windows for drawing purpose.
A base class for most all the KiCad significant classes used in schematics and boards.
KICAD_T Type() const
Returns the type of object.
Helper for storing and iterating over GAL_LAYER_IDs.
std::set< int > m_netCodes
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
LSET is a set of PCB_LAYER_IDs.
EDA_MSG_PANEL items for displaying messages.
Handle the data for a net.
Wrapper class, so you can iterate through NETINFO_ITEM*s, not std::pair<int/wxString,...
Container for NETINFO_ITEM elements, which are the nets.
void RemoveUnusedNets(BOARD_COMMIT *aCommit)
unsigned GetNetCount() const
void buildListOfNets()
Rebuild the list of NETINFO_ITEMs.
Store information read from a netlist along with the flags used to update the NETLIST in the BOARD.
Describe the page size and margins of a paper page on which to eventually print or plot.
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
The main frame for Pcbnew.
A set of BOARD_ITEMs (i.e., without duplicates).
Parameters and options when plotting/printing a board.
A holder to handle information on schematic or board items.
A progress reporter interface for use in multi-threaded environments.
Container for project specific data.
A pure virtual class used to derive REPORTER objects from.
Represent a set of closed polygons.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
Handle a list of polygons defining a copper zone.
const std::function< void(const wxString &msg, BOARD_ITEM *itemA, BOARD_ITEM *itemB, const VECTOR2I &pt)> OUTLINE_ERROR_HANDLER
const INSPECTOR_FUNC & INSPECTOR
static constexpr void hash_combine(std::size_t &seed)
This is a dummy function to take the final case of hash_combine below.
wxString LayerName(int aLayer)
Returns the default display name for a given layer.
GAL_LAYER_ID
GAL layers are "virtual" layers, i.e.
PCB_LAYER_ID
A quick note on layer IDs:
std::vector< ZONE * > ZONES
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
bool operator()(const BOARD_ITEM *aFirst, const BOARD_ITEM *aSecond) const
A struct recording the isolated and single-pad islands within a zone.
Container to hold information pertinent to a layer of a BOARD.
int m_opposite
Similar layer on opposite side of the board, if any.
static LAYER_T ParseType(const char *aType)
Convert a string to a LAYER_T.
LAYER_T m_type
The type of the layer.
static const char * ShowType(LAYER_T aType)
Convert a LAYER_T enum to a string representation of the layer type.
wxString m_name
The canonical name of the layer.
wxString m_userName
The user defined name of the layer.
int m_number
The layer ID.
bool operator==(const PTR_LAYER_CACHE_KEY &other) const
bool operator==(const PTR_PTR_CACHE_KEY &other) const
bool operator==(const PTR_PTR_LAYER_CACHE_KEY &other) const
std::size_t operator()(const PTR_LAYER_CACHE_KEY &k) const
std::size_t operator()(const PTR_PTR_CACHE_KEY &k) const
std::size_t operator()(const PTR_PTR_LAYER_CACHE_KEY &k) const
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
@ PCB_GENERATOR_T
class PCB_GENERATOR, generator on a layer
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
@ PCB_ZONE_T
class ZONE, a copper pour area
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
@ PCB_NETINFO_T
class NETINFO_ITEM, a description of a net
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
ZONE_BORDER_DISPLAY_STYLE
Zone border styles.