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;
40class BOARD_ITEM;
42class FOOTPRINT;
43class NETINFO_ITEM;
44class PAD;
45class PCB_SHAPE;
46class PCB_TEXT;
47class REPORTER;
48
49
58{
59public:
60 TARGET3001_PCB_BUILDER( BOARD* aBoard, const TARGET3001::PROJECT& aProject, REPORTER* aReporter );
61
62 void Build();
63
65 const wxString& DesignRules() const { return m_designRules; }
66
68 TARGET3001::LAYER_FUNCTION LayerFunction( int aLayer ) const;
69
70private:
71 void buildLayerMap();
72 void buildNets();
73 void buildComponents();
74 void buildSignalCopper();
75 void buildFreeItems();
76 void buildPourAreas();
77
78 void addFootprint( const TARGET3001::ELEMENT& aComponent );
79
81 void addItem( const TARGET3001::ELEMENT& aElem, BOARD_ITEM_CONTAINER* aParent, FOOTPRINT* aFootprint,
82 bool aIsTrack );
83
85 void addShape( const TARGET3001::ELEMENT& aElem, BOARD_ITEM_CONTAINER* aParent, FOOTPRINT* aFootprint,
86 bool aIsTrack, PCB_LAYER_ID aLayer );
87
89 std::vector<std::unique_ptr<PCB_SHAPE>> fiducialShapes( const TARGET3001::ELEMENT& aElem,
90 BOARD_ITEM_CONTAINER* aParent ) const;
91
92 void addPad( const TARGET3001::ELEMENT& aElem, FOOTPRINT* aFootprint );
93 void addVia( const TARGET3001::ELEMENT& aElem );
94 void addText( const TARGET3001::ELEMENT& aElem, BOARD_ITEM_CONTAINER* aParent, FOOTPRINT* aFootprint,
95 PCB_LAYER_ID aLayer );
96 void configureText( PCB_TEXT* aText, const TARGET3001::ELEMENT& aElem, PCB_LAYER_ID aLayer );
97
99 std::optional<PCB_LAYER_ID> mapLayer( int aLayer ) const;
100
102 std::optional<PCB_LAYER_ID> pourCopperLayer( int aLayer ) const;
103
104 bool isCopper( int aLayer ) const;
105
108
110 void connectAuraPads();
111
112 NETINFO_ITEM* net( uint16_t aSignal ) const;
113
114 VECTOR2I toKi( int32_t aX, int32_t aY ) const { return VECTOR2I( aX, -aY ); }
115
117 bool elementOutline( const TARGET3001::ELEMENT& aElem, SHAPE_POLY_SET& aOut ) const;
118
120 void mergeContour( const TARGET3001::ELEMENT& aElem );
121
123 std::optional<LSET> padstackLayers( int aLayer ) const;
124
126 void addPadstackCuts( const BOARD_ITEM& aItem, int aPadstack );
127
128 struct AURA_PAD
129 {
131 uint16_t signal;
132 std::set<PCB_LAYER_ID> noAura;
133 };
134
142
146
147 std::map<int, PCB_LAYER_ID> m_layerMap;
148 std::vector<int> m_copperStack;
149 std::map<uint16_t, NETINFO_ITEM*> m_nets;
151 std::map<std::pair<int, int>, SHAPE_POLY_SET> m_copperFills;
152 std::vector<POUR_AREA> m_pourAreas;
153 std::optional<int> m_contourLayer;
156 std::map<int, SHAPE_POLY_SET> m_pourKeepouts;
157
159 std::map<uint16_t, std::map<int, int>> m_signalClearances;
160 std::vector<AURA_PAD> m_auraPads;
161 std::set<std::pair<uint16_t, PCB_LAYER_ID>> m_pourLayers;
164};
165
166#endif // TARGET3001_PCB_BUILDER_H
BOX2< VECTOR2I > BOX2I
Definition box2.h:914
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:85
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.
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::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)
void connectAuraPads()
Connect pads to areas of their own signal the way their aura and NO_AURA layers do.
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.
std::set< std::pair< uint16_t, PCB_LAYER_ID > > m_pourLayers
(signal, KiCad layer) holding an area
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< LSET > padstackLayers(int aLayer) const
Copper, mask and paste layers of the padstack a pad layer >= 101 selects.
void addText(const TARGET3001::ELEMENT &aElem, BOARD_ITEM_CONTAINER *aParent, FOOTPRINT *aFootprint, PCB_LAYER_ID aLayer)
void mergeContour(const TARGET3001::ELEMENT &aElem)
Grow the board contour box by the defining points of an element, ignoring line widths.
const wxString & DesignRules() const
Custom rules that carry what KiCad cannot store on the items themselves, empty when none apply.
void configureText(PCB_TEXT *aText, const TARGET3001::ELEMENT &aElem, PCB_LAYER_ID aLayer)
VECTOR2I toKi(int32_t aX, int32_t aY) const
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
std::vector< AURA_PAD > m_auraPads
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.
One element of any class.
std::set< PCB_LAYER_ID > noAura
layers where the area joins the pad solidly
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708