KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_kicad_iface.h
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2013-2016 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Tomasz Wlostowski <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef __PNS_KICAD_IFACE_H
23#define __PNS_KICAD_IFACE_H
24
25#include <set>
26#include <unordered_set>
27#include <unordered_map>
28#include <vector>
29
30#include "pns_router.h"
31
35
36class BOARD;
37class BOARD_COMMIT;
38class PCB_TEXT;
40class PCB_TOOL_BASE;
41class FOOTPRINT;
42class PCB_BARCODE;
44class PAD;
45class EDA_TEXT;
47class BOARD_ITEM;
48class EDA_GROUP;
49
50namespace PNS
51{
52 class SIZES_SETTINGS;
53}
54
55namespace KIGFX
56{
57 class VIEW;
58}
59
61{
62public:
64 ~PNS_KICAD_IFACE_BASE() override;
65
66 void EraseView() override {};
67 void SetBoard( BOARD* aBoard );
68 void SyncWorld( PNS::NODE* aWorld ) override;
69 bool IsAnyLayerVisible( const PNS_LAYER_RANGE& aLayer ) const override { return true; };
70 bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override;
71 bool IsFlashedOnLayer( const PNS::ITEM* aItem, const PNS_LAYER_RANGE& aLayer ) const override;
72 bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; };
73 bool IsPNSCopperLayer( int aPNSLayer ) const override;
74 bool IsKicadCopperLayer( PCB_LAYER_ID aPcbnewLayer ) const;
75 void HideItem( PNS::ITEM* aItem ) override {}
76 void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
77 int aFlags = 0 ) override {}
78 void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) override {}
79 void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet ) override {}
80 void AddItem( PNS::ITEM* aItem ) override;
81 void UpdateItem( PNS::ITEM* aItem ) override;
82 void RemoveItem( PNS::ITEM* aItem ) override;
83 void Commit() override {}
84 bool ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* aStartItem, PNS::NET_HANDLE aNet,
85 VECTOR2D aStartPosition ) override;
86 int StackupHeight( int aFirstLayer, int aSecondLayer ) const override;
87
88 int GetNetCode( PNS::NET_HANDLE aNet ) const override { return -1; }
89 wxString GetNetName( PNS::NET_HANDLE aNet ) const override { return wxEmptyString; }
90 void UpdateNet( PNS::NET_HANDLE aNet ) override {}
92
94
95 long long int CalculateRoutedPathLength( const PNS::ITEM_SET& aLine, const PNS::SOLID* aStartPad,
96 const PNS::SOLID* aEndPad, const NETCLASS* aNetClass ) override;
97 int64_t CalculateRoutedPathDelay( const PNS::ITEM_SET& aLine, const PNS::SOLID* aStartPad,
98 const PNS::SOLID* aEndPad, const NETCLASS* aNetClass ) override;
99 int64_t CalculateLengthForDelay( int64_t aDesiredDelay, int aWidth, bool aIsDiffPairCoupled,
100 int aDiffPairCouplingGap, int aPNSLayer, const NETCLASS* aNetClass ) override;
101 int64_t CalculateDelayForShapeLineChain( const SHAPE_LINE_CHAIN& aShape, int aWidth, bool aIsDiffPairCoupled,
102 int aDiffPairCouplingGap, int aPNSLayer,
103 const NETCLASS* aNetClass ) override;
104
105 PCB_LAYER_ID GetBoardLayerFromPNSLayer( int aLayer ) const override;
106 int GetPNSLayerFromBoardLayer( PCB_LAYER_ID aLayer ) const override;
108 long long& aExtraLength, long long& aExtraDelay ) const override;
109 long long GetNetBoardLength( PNS::NET_HANDLE aNet ) const override;
110 void RemoveBoardConnected( const std::vector<const PNS::ITEM*>& aJoined,
111 std::set<PNS::ITEM*>& aItems ) const override;
112 bool TouchesCopperZone( const PNS::ITEM* aItem ) const override;
113
115 void SetStartLayerFromPNS( int aLayer ) { m_startLayer = aLayer; }
116
118
119 virtual PNS::NODE* GetWorld() const override { return m_world; };
120
121 BOARD* GetBoard() const { return m_board; }
122
123 virtual EDA_UNITS GetUnits() const { return EDA_UNITS::MM; };
124
127
128 std::vector<LENGTH_DELAY_CALCULATION_ITEM> GetLengthDelayCalculationItems( const PNS::ITEM_SET& aLine,
129 const NETCLASS* aNetClass ) const;
130
131protected:
134
135 std::vector<std::unique_ptr<PNS::SOLID>> syncPad( PAD* aPad );
136 std::unique_ptr<PNS::SEGMENT> syncTrack( PCB_TRACK* aTrack );
137 std::unique_ptr<PNS::ARC> syncArc( PCB_ARC* aArc );
138 std::unique_ptr<PNS::VIA> syncVia( PCB_VIA* aVia );
139 bool syncTextItem( PNS::NODE* aWorld, BOARD_ITEM* aItem, PCB_LAYER_ID aLayer );
140 bool syncDimension( PNS::NODE* aWorld, PCB_DIMENSION_BASE* aDimension );
141 bool syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aItem );
142 bool syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_SET* aBoardOutline );
143 bool syncBarcode( PNS::NODE* aWorld, PCB_BARCODE* aBarcode );
144 bool inheritTrackWidthAndDpGap( PNS::ITEM* aItem, const VECTOR2I& aStartPosition, int* aInheritedWidth, int *aInheritedGap );
145 std::vector<LENGTH_DELAY_CALCULATION_ITEM> getLengthDelayCalculationItems( const PNS::ITEM_SET& aLine,
146 const NETCLASS* aNetClass ) const;
147
148protected:
151 int m_startLayer; // The starting layer, in PNS layer coordinates
152};
153
155{
156public:
158 ~PNS_KICAD_IFACE() override;
159
160 virtual void SetHostTool( PCB_TOOL_BASE* aTool );
161
162 void SetView( KIGFX::VIEW* aView );
163 void EraseView() override;
164 bool IsAnyLayerVisible( const PNS_LAYER_RANGE& aLayer ) const override;
165 bool IsItemVisible( const PNS::ITEM* aItem ) const override;
166 void HideItem( PNS::ITEM* aItem ) override;
167 void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
168 int aFlags = 0 ) override;
169 void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) override;
170 void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet ) override;
171 void Commit() override;
172 void AddItem( PNS::ITEM* aItem ) override;
173 void UpdateItem( PNS::ITEM* aItem ) override;
174 void RemoveItem( PNS::ITEM* aItem ) override;
175
176 int GetNetCode( PNS::NET_HANDLE aNet ) const override;
177 wxString GetNetName( PNS::NET_HANDLE aNet ) const override;
178 void UpdateNet( PNS::NET_HANDLE aNet ) override;
180 long long& aExtraLength, long long& aExtraDelay ) const override;
181
182 EDA_UNITS GetUnits() const override;
183
184 void SetCommitFlags( int aCommitFlags ) { m_commitFlags = aCommitFlags; }
185
187 void SetIndependentPads( const std::set<PAD*>& aPads ) { m_independentPads = aPads; }
188
189protected:
191 void modifyBoardItem( PNS::ITEM* aItem, BOARD_COMMIT& aCommit );
192
193 void clearPreviewItems();
194
198 void addPreviewItem( ROUTER_PREVIEW_ITEM* aItem );
199
200 struct OFFSET
201 {
203 };
204
205 std::map<PAD*, OFFSET> m_fpOffsets;
206 std::set<PAD*> m_independentPads;
208
210 std::vector<ROUTER_PREVIEW_ITEM*> m_previewItems;
211
212 std::unordered_set<BOARD_ITEM*> m_hiddenItems;
213
214 std::unordered_map<BOARD_ITEM*, EDA_GROUP*> m_itemGroups;
215 std::unordered_map<BOARD_ITEM*, std::vector<BOARD_ITEM*>> m_replacementMap;
216
218 std::unique_ptr<BOARD_COMMIT> m_commit;
220};
221
222
223#endif
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
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
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:43
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:94
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:68
Lightweight class which holds a pad, via, or a routed trace outline.
A collection of nets and the parameters used to route or test these nets.
Definition netclass.h:44
Definition pad.h:61
Abstract dimension API.
Base class for PNS router board items.
Definition pns_item.h:98
Keep the router "world" - i.e.
Definition pns_node.h:244
void DisplayItem(const PNS::ITEM *aItem, int aClearance, bool aEdit=false, int aFlags=0) override
bool syncGraphicalItem(PNS::NODE *aWorld, PCB_SHAPE *aItem)
void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, PNS::NET_HANDLE aNet) override
void AddItem(PNS::ITEM *aItem) override
wxString GetNetName(PNS::NET_HANDLE aNet) const override
bool syncDimension(PNS::NODE *aWorld, PCB_DIMENSION_BASE *aDimension)
virtual EDA_UNITS GetUnits() const
PNS::DEBUG_DECORATOR * m_debugDecorator
void SetDebugDecorator(PNS::DEBUG_DECORATOR *aDec)
bool syncZone(PNS::NODE *aWorld, ZONE *aZone, SHAPE_POLY_SET *aBoardOutline)
void SetBoard(BOARD *aBoard)
long long int CalculateRoutedPathLength(const PNS::ITEM_SET &aLine, const PNS::SOLID *aStartPad, const PNS::SOLID *aEndPad, const NETCLASS *aNetClass) override
virtual PNS::NODE * GetWorld() const override
int64_t CalculateRoutedPathDelay(const PNS::ITEM_SET &aLine, const PNS::SOLID *aStartPad, const PNS::SOLID *aEndPad, const NETCLASS *aNetClass) override
void RemoveBoardConnected(const std::vector< const PNS::ITEM * > &aJoined, std::set< PNS::ITEM * > &aItems) const override
Remove from aItems every item the board already joins to one of aJoined through objects the router do...
std::unique_ptr< PNS::ARC > syncArc(PCB_ARC *aArc)
void RemoveItem(PNS::ITEM *aItem) override
bool GetSignalAggregate(PNS::NET_HANDLE aNetP, PNS::NET_HANDLE aNetN, long long &aExtraLength, long long &aExtraDelay) const override
bool IsPNSCopperLayer(int aPNSLayer) const override
int64_t CalculateLengthForDelay(int64_t aDesiredDelay, int aWidth, bool aIsDiffPairCoupled, int aDiffPairCouplingGap, int aPNSLayer, const NETCLASS *aNetClass) override
void DisplayPathLine(const SHAPE_LINE_CHAIN &aLine, int aImportance) override
PNS::RULE_RESOLVER * GetRuleResolver() override
bool TouchesCopperZone(const PNS::ITEM *aItem) const override
Copper zones are absent from NODE joints, so tail pruning must keep items that touch one.
bool syncTextItem(PNS::NODE *aWorld, BOARD_ITEM *aItem, PCB_LAYER_ID aLayer)
std::vector< LENGTH_DELAY_CALCULATION_ITEM > getLengthDelayCalculationItems(const PNS::ITEM_SET &aLine, const NETCLASS *aNetClass) const
bool IsAnyLayerVisible(const PNS_LAYER_RANGE &aLayer) const override
bool IsKicadCopperLayer(PCB_LAYER_ID aPcbnewLayer) const
bool inheritTrackWidthAndDpGap(PNS::ITEM *aItem, const VECTOR2I &aStartPosition, int *aInheritedWidth, int *aInheritedGap)
std::vector< std::unique_ptr< PNS::SOLID > > syncPad(PAD *aPad)
int GetNetCode(PNS::NET_HANDLE aNet) const override
void HideItem(PNS::ITEM *aItem) override
void SetStartLayerFromPCBNew(PCB_LAYER_ID aLayer)
void Commit() override
bool syncBarcode(PNS::NODE *aWorld, PCB_BARCODE *aBarcode)
bool IsItemVisible(const PNS::ITEM *aItem) const override
bool IsFlashedOnLayer(const PNS::ITEM *aItem, int aLayer) const override
long long GetNetBoardLength(PNS::NET_HANDLE aNet) const override
PCB_LAYER_ID GetBoardLayerFromPNSLayer(int aLayer) const override
BOARD * GetBoard() const
void UpdateNet(PNS::NET_HANDLE aNet) override
void SyncWorld(PNS::NODE *aWorld) override
int StackupHeight(int aFirstLayer, int aSecondLayer) const override
int64_t CalculateDelayForShapeLineChain(const SHAPE_LINE_CHAIN &aShape, int aWidth, bool aIsDiffPairCoupled, int aDiffPairCouplingGap, int aPNSLayer, const NETCLASS *aNetClass) override
PNS::DEBUG_DECORATOR * GetDebugDecorator() override
std::unique_ptr< PNS::SEGMENT > syncTrack(PCB_TRACK *aTrack)
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
PNS::NET_HANDLE GetOrphanedNetHandle() override
std::unique_ptr< PNS::VIA > syncVia(PCB_VIA *aVia)
int GetPNSLayerFromBoardLayer(PCB_LAYER_ID aLayer) const override
void SetStartLayerFromPNS(int aLayer)
PNS_LAYER_RANGE SetLayersFromPCBNew(PCB_LAYER_ID aStartLayer, PCB_LAYER_ID aEndLayer)
void EraseView() override
std::vector< LENGTH_DELAY_CALCULATION_ITEM > GetLengthDelayCalculationItems(const PNS::ITEM_SET &aLine, const NETCLASS *aNetClass) const
void UpdateItem(PNS::ITEM *aItem) override
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, PNS::NET_HANDLE aNet, VECTOR2D aStartPosition) override
std::vector< ROUTER_PREVIEW_ITEM * > m_previewItems
Each preview item is in the view directly so it draws at its own layer's place.
void SetView(KIGFX::VIEW *aView)
void RemoveItem(PNS::ITEM *aItem) override
void AddItem(PNS::ITEM *aItem) override
void UpdateItem(PNS::ITEM *aItem) override
std::map< PAD *, OFFSET > m_fpOffsets
int GetNetCode(PNS::NET_HANDLE aNet) const override
virtual void SetHostTool(PCB_TOOL_BASE *aTool)
void DisplayItem(const PNS::ITEM *aItem, int aClearance, bool aEdit=false, int aFlags=0) override
std::unique_ptr< BOARD_COMMIT > m_commit
void addPreviewItem(ROUTER_PREVIEW_ITEM *aItem)
Add a preview item to the view and take ownership of it.
void modifyBoardItem(PNS::ITEM *aItem, BOARD_COMMIT &aCommit)
void EraseView() override
void HideItem(PNS::ITEM *aItem) override
void UpdateNet(PNS::NET_HANDLE aNet) override
BOARD_CONNECTED_ITEM * createBoardItem(PNS::ITEM *aItem)
KIGFX::VIEW * m_view
std::set< PAD * > m_independentPads
void DisplayPathLine(const SHAPE_LINE_CHAIN &aLine, int aImportance) override
std::unordered_map< BOARD_ITEM *, EDA_GROUP * > m_itemGroups
bool IsItemVisible(const PNS::ITEM *aItem) const override
std::unordered_set< BOARD_ITEM * > m_hiddenItems
EDA_UNITS GetUnits() const override
bool IsAnyLayerVisible(const PNS_LAYER_RANGE &aLayer) const override
PCB_TOOL_BASE * m_tool
bool GetSignalAggregate(PNS::NET_HANDLE aNetP, PNS::NET_HANDLE aNetN, long long &aExtraLength, long long &aExtraDelay) const override
void Commit() override
void SetIndependentPads(const std::set< PAD * > &aPads)
Pads that move on their own. A moved pad otherwise carries its footprint.
void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, PNS::NET_HANDLE aNet) override
void SetCommitFlags(int aCommitFlags)
std::unordered_map< BOARD_ITEM *, std::vector< BOARD_ITEM * > > m_replacementMap
wxString GetNetName(PNS::NET_HANDLE aNet) const override
~PNS_KICAD_IFACE() override
Represent a contiguous set of PCB layers.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Represent a set of closed polygons.
Handle a list of polygons defining a copper zone.
Definition zone.h:70
EDA_UNITS
Definition eda_units.h:44
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:56
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30
Push and Shove diff pair dimensions (gap) settings dialog.
void * NET_HANDLE
Definition pns_item.h:55
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708
VECTOR2< double > VECTOR2D
Definition vector2d.h:707