KiCad PCB EDA Suite
Loading...
Searching...
No Matches
target3001_pcb_builder.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 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef TARGET3001_PCB_BUILDER_H
21#define TARGET3001_PCB_BUILDER_H
22
23#include <map>
24#include <memory>
25#include <optional>
26#include <set>
27#include <vector>
28
30#include <layer_ids.h>
31#include <lset.h>
32#include <math/box2.h>
33#include <math/vector2d.h>
34#include <wx/string.h>
35
38
39class BOARD;
41class BOARD_ITEM;
43class FOOTPRINT;
44class NETINFO_ITEM;
45class PAD;
46class PCB_SHAPE;
47class PCB_TEXT;
48class REPORTER;
49class ZONE;
50
51
60{
61public:
62 TARGET3001_PCB_BUILDER( BOARD* aBoard, const TARGET3001::PROJECT& aProject, REPORTER* aReporter );
63
64 void Build();
65
67 const wxString& DesignRules() const { return m_designRules; }
68
70 TARGET3001::LAYER_FUNCTION LayerFunction( int aLayer ) const;
71
72private:
73 void buildLayerMap();
74 void buildNets();
75 void buildComponents();
76 void buildSignalCopper();
77
79 void buildAreaSpokes( const std::vector<const TARGET3001::ELEMENT*>& aSpokes );
80
81 void buildFreeItems();
82 void buildPourAreas();
83 void buildPolygonPours();
84
86 void buildThermalGaps();
87
88 void addFootprint( const TARGET3001::ELEMENT& aComponent );
89
91 void addItem( const TARGET3001::ELEMENT& aElem, BOARD_ITEM_CONTAINER* aParent, FOOTPRINT* aFootprint,
92 bool aIsTrack );
93
95 void addShape( const TARGET3001::ELEMENT& aElem, BOARD_ITEM_CONTAINER* aParent, FOOTPRINT* aFootprint,
96 bool aIsTrack, PCB_LAYER_ID aLayer );
97
99 std::vector<std::unique_ptr<PCB_SHAPE>> fiducialShapes( const TARGET3001::ELEMENT& aElem,
100 BOARD_ITEM_CONTAINER* aParent ) const;
101
102 void addPad( const TARGET3001::ELEMENT& aElem, FOOTPRINT* aFootprint );
103 void addVia( const TARGET3001::ELEMENT& aElem );
104 void addText( const TARGET3001::ELEMENT& aElem, BOARD_ITEM_CONTAINER* aParent, FOOTPRINT* aFootprint,
105 PCB_LAYER_ID aLayer );
106 void configureText( PCB_TEXT* aText, const TARGET3001::ELEMENT& aElem, PCB_LAYER_ID aLayer );
107
109 std::optional<PCB_LAYER_ID> mapLayer( int aLayer ) const;
110
112 std::optional<PCB_LAYER_ID> pourCopperLayer( int aLayer ) const;
113
115 std::optional<PCB_LAYER_ID> polygonLayer( const TARGET3001::POLYGON_POUR& aPoly ) const;
116
117 bool isCopper( int aLayer ) const;
118
121
123 void buildAuraRules();
124
126 void buildPolygonRules();
127
129 void tagAura( BOARD_CONNECTED_ITEM& aItem, const TARGET3001::ELEMENT_BASE& aBase, int aAura );
130
131 NETINFO_ITEM* net( uint16_t aSignal ) const;
132
133 VECTOR2I toKi( int32_t aX, int32_t aY ) const { return VECTOR2I( aX, -aY ); }
134
136 bool elementOutline( const TARGET3001::ELEMENT& aElem, SHAPE_POLY_SET& aOut ) const;
137
139 void noteContour( const TARGET3001::ELEMENT& aElem );
140
142 std::optional<LSET> padstackLayers( int aLayer ) const;
143
145 void addPadstackCuts( const BOARD_ITEM& aItem, int aPadstack );
146
153
157
158 std::map<int, PCB_LAYER_ID> m_layerMap;
159 std::vector<int> m_copperStack;
160 std::map<uint16_t, NETINFO_ITEM*> m_nets;
162 std::map<std::pair<int, int>, SHAPE_POLY_SET> m_copperFills;
163 std::vector<POUR_AREA> m_pourAreas;
164 std::optional<int> m_contourLayer;
166 std::map<int, SHAPE_POLY_SET> m_pourKeepouts;
167 std::map<int64_t, SHAPE_POLY_SET> m_polygonFills;
168 std::map<int64_t, SHAPE_POLY_SET> m_polygonSpokes;
169 std::vector<std::pair<ZONE*, int64_t>> m_polygonZones;
171 std::set<int> m_polygonAuras;
172 bool m_hasPolygonPours = false;
173
175 std::map<uint16_t, std::map<int, int>> m_signalClearances;
176 std::set<int> m_auraValues;
177 std::set<PCB_LAYER_ID> m_noAuraLayers;
178 std::set<std::pair<uint16_t, PCB_LAYER_ID>> m_pourLayers;
181};
182
183#endif // TARGET3001_PCB_BUILDER_H
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
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...
Definition board_item.h:99
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:411
Handle the data for a net.
Definition netinfo.h:50
Definition pad.h:61
A pure virtual class used to derive REPORTER objects from.
Definition reporter.h:73
Represent a set of closed polygons.
Maps TARGET 3001!
TARGET3001::LAYER_FUNCTION LayerFunction(int aLayer) const
Function of a TARGET 3001! board layer in this project.
const TARGET3001::PROJECT & m_project
std::map< uint16_t, NETINFO_ITEM * > m_nets
by signal ID
std::vector< POUR_AREA > m_pourAreas
void addShape(const TARGET3001::ELEMENT &aElem, BOARD_ITEM_CONTAINER *aParent, FOOTPRINT *aFootprint, bool aIsTrack, PCB_LAYER_ID aLayer)
Add the graphic or track form of aElem on one KiCad layer.
void addVia(const TARGET3001::ELEMENT &aElem)
std::map< int, SHAPE_POLY_SET > m_pourKeepouts
KiCad layer -> pour keepout.
void addFootprint(const TARGET3001::ELEMENT &aComponent)
std::vector< int > m_copperStack
TARGET layers, top to bottom.
void addItem(const TARGET3001::ELEMENT &aElem, BOARD_ITEM_CONTAINER *aParent, FOOTPRINT *aFootprint, bool aIsTrack)
Add one board element to aParent; footprint items are passed with their footprint.
void buildAreaSpokes(const std::vector< const TARGET3001::ELEMENT * > &aSpokes)
Turn the spokes an old style area stores into thermal reliefs on the pads they start in.
std::vector< std::unique_ptr< PCB_SHAPE > > fiducialShapes(const TARGET3001::ELEMENT &aElem, BOARD_ITEM_CONTAINER *aParent) const
Strokes and discs that draw a fiducial mark, not yet assigned a layer.
std::vector< std::pair< ZONE *, int64_t > > m_polygonZones
thermal polygon zones and their POLYGONID
std::optional< PCB_LAYER_ID > pourCopperLayer(int aLayer) const
Copper layer that an area or deletion layer applies to.
void buildAreaClearanceRules()
Clearance rules between copper areas and each signal's tracks and vias.
bool isCopper(int aLayer) const
NETINFO_ITEM * net(uint16_t aSignal) const
void addPad(const TARGET3001::ELEMENT &aElem, FOOTPRINT *aFootprint)
bool elementOutline(const TARGET3001::ELEMENT &aElem, SHAPE_POLY_SET &aOut) const
Outline of a filled element (rectangle, triangle, disc, stroked line or arc) in KiCad coordinates.
void buildAuraRules()
Rules that keep areas the aura distance from pads and vias, except on their NO_AURA layers.
std::set< std::pair< uint16_t, PCB_LAYER_ID > > m_pourLayers
(signal, KiCad layer) holding an area
std::map< int64_t, SHAPE_POLY_SET > m_polygonSpokes
POLYGONID -> stored thermal spokes.
std::map< std::pair< int, int >, SHAPE_POLY_SET > m_copperFills
(net, KiCad layer) -> filled copper
std::map< uint16_t, std::map< int, int > > m_signalClearances
Track and via clearances counted per signal, then per clearance value.
TARGET3001_PCB_BUILDER(BOARD *aBoard, const TARGET3001::PROJECT &aProject, REPORTER *aReporter)
void addPadstackCuts(const BOARD_ITEM &aItem, int aPadstack)
Cut aItem, grown per layer, from the pours of the deletion layers padstack aPadstack lists.
std::optional< PCB_LAYER_ID > polygonLayer(const TARGET3001::POLYGON_POUR &aPoly) const
Copper layer of a signal polygon that can become a zone.
std::optional< LSET > padstackLayers(int aLayer) const
Copper, mask and paste layers of the padstack a pad layer >= 101 selects.
void buildThermalGaps()
Thermal gaps the stored fill leaves around spoked pads, as zone defaults and pad or footprint overrid...
void addText(const TARGET3001::ELEMENT &aElem, BOARD_ITEM_CONTAINER *aParent, FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer)
const wxString & DesignRules() const
Custom rules that carry what KiCad cannot store on the items themselves, empty when none apply.
void tagAura(BOARD_CONNECTED_ITEM &aItem, const TARGET3001::ELEMENT_BASE &aBase, int aAura)
Tag a pad or via with its aura so the aura rules can match it.
void buildPolygonRules()
Rules for the board contour and foreign polygon distances each signal polygon keeps.
std::set< int > m_auraValues
distinct aura distances above zero
std::map< int64_t, SHAPE_POLY_SET > m_polygonFills
POLYGONID -> stored fill without spokes.
std::set< int > m_polygonEdgeClearances
void noteContour(const TARGET3001::ELEMENT &aElem)
Record whether a board contour stroke carries a clearance.
void configureText(PCB_TEXT *aText, const TARGET3001::ELEMENT &aElem, PCB_LAYER_ID aLayer)
VECTOR2I toKi(int32_t aX, int32_t aY) const
std::set< PCB_LAYER_ID > m_noAuraLayers
copper layers some NO_AURA list names
std::optional< int > m_contourLayer
first TARGET layer holding the contour
std::optional< PCB_LAYER_ID > mapLayer(int aLayer) const
Copper or graphic layer for a board element, if KiCad has a place for it.
std::map< int, PCB_LAYER_ID > m_layerMap
bool m_contourCarvesNothing
a contour stroke has no clearance
Handle a list of polygons defining a copper zone.
Definition zone.h:70
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
LAYER_FUNCTION
Board layer function codes stored per layer in the project header.
Fields shared by every drawable element.
One element of any class.
Copper polygon of a signal, stored in a "$%&POLY" signal property.
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708