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 along
19 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef __PNS_KICAD_IFACE_H
23#define __PNS_KICAD_IFACE_H
24
25#include <unordered_set>
26#include <unordered_map>
27#include <vector>
28
29#include "pns_router.h"
30
33
34class BOARD;
35class BOARD_COMMIT;
36class PCB_TEXT;
38class PCB_TOOL_BASE;
39class FOOTPRINT;
40class PCB_BARCODE;
41class PAD;
42class EDA_TEXT;
44class BOARD_ITEM;
45class EDA_GROUP;
46
47namespace PNS
48{
49 class SIZES_SETTINGS;
50}
51
52namespace KIGFX
53{
54 class VIEW;
55}
56
58{
59public:
61 ~PNS_KICAD_IFACE_BASE() override;
62
63 void EraseView() override {};
64 void SetBoard( BOARD* aBoard );
65 void SyncWorld( PNS::NODE* aWorld ) override;
66 bool IsAnyLayerVisible( const PNS_LAYER_RANGE& aLayer ) const override { return true; };
67 bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override;
68 bool IsFlashedOnLayer( const PNS::ITEM* aItem, const PNS_LAYER_RANGE& aLayer ) const override;
69 bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; };
70 bool IsPNSCopperLayer( int aPNSLayer ) const override;
71 bool IsKicadCopperLayer( PCB_LAYER_ID aPcbnewLayer ) const;
72 void HideItem( PNS::ITEM* aItem ) override {}
73 void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
74 int aFlags = 0 ) override {}
75 void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) override {}
76 void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet ) override {}
77 void AddItem( PNS::ITEM* aItem ) override;
78 void UpdateItem( PNS::ITEM* aItem ) override;
79 void RemoveItem( PNS::ITEM* aItem ) override;
80 void Commit() override {}
81 bool ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* aStartItem, PNS::NET_HANDLE aNet,
82 VECTOR2D aStartPosition ) override;
83 int StackupHeight( int aFirstLayer, int aSecondLayer ) const override;
84
85 int GetNetCode( PNS::NET_HANDLE aNet ) const override { return -1; }
86 wxString GetNetName( PNS::NET_HANDLE aNet ) const override { return wxEmptyString; }
87 void UpdateNet( PNS::NET_HANDLE aNet ) override {}
89
91
92 long long int CalculateRoutedPathLength( const PNS::ITEM_SET& aLine, const PNS::SOLID* aStartPad,
93 const PNS::SOLID* aEndPad, const NETCLASS* aNetClass ) override;
94 int64_t CalculateRoutedPathDelay( const PNS::ITEM_SET& aLine, const PNS::SOLID* aStartPad,
95 const PNS::SOLID* aEndPad, const NETCLASS* aNetClass ) override;
96 int64_t CalculateLengthForDelay( int64_t aDesiredDelay, int aWidth, bool aIsDiffPairCoupled,
97 int aDiffPairCouplingGap, int aPNSLayer, const NETCLASS* aNetClass ) override;
98 int64_t CalculateDelayForShapeLineChain( const SHAPE_LINE_CHAIN& aShape, int aWidth, bool aIsDiffPairCoupled,
99 int aDiffPairCouplingGap, int aPNSLayer,
100 const NETCLASS* aNetClass ) override;
101
102 PCB_LAYER_ID GetBoardLayerFromPNSLayer( int aLayer ) const override;
103 int GetPNSLayerFromBoardLayer( PCB_LAYER_ID aLayer ) const override;
104
106 void SetStartLayerFromPNS( int aLayer ) { m_startLayer = aLayer; }
107
109
110 virtual PNS::NODE* GetWorld() const override { return m_world; };
111
112 BOARD* GetBoard() const { return m_board; }
113
114 virtual EDA_UNITS GetUnits() const { return EDA_UNITS::MM; };
115
118
119protected:
122
123 std::vector<std::unique_ptr<PNS::SOLID>> syncPad( PAD* aPad );
124 std::unique_ptr<PNS::SEGMENT> syncTrack( PCB_TRACK* aTrack );
125 std::unique_ptr<PNS::ARC> syncArc( PCB_ARC* aArc );
126 std::unique_ptr<PNS::VIA> syncVia( PCB_VIA* aVia );
127 bool syncTextItem( PNS::NODE* aWorld, BOARD_ITEM* aItem, PCB_LAYER_ID aLayer );
128 bool syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aItem );
129 bool syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_SET* aBoardOutline );
130 bool syncBarcode( PNS::NODE* aWorld, PCB_BARCODE* aBarcode );
131 bool inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth );
132 std::vector<LENGTH_DELAY_CALCULATION_ITEM> getLengthDelayCalculationItems( const PNS::ITEM_SET& aLine,
133 const NETCLASS* aNetClass ) const;
134
135protected:
138 int m_startLayer; // The starting layer, in PNS layer coordinates
139};
140
142{
143public:
145 ~PNS_KICAD_IFACE() override;
146
147 virtual void SetHostTool( PCB_TOOL_BASE* aTool );
148
149 void SetView( KIGFX::VIEW* aView );
150 void EraseView() override;
151 bool IsAnyLayerVisible( const PNS_LAYER_RANGE& aLayer ) const override;
152 bool IsItemVisible( const PNS::ITEM* aItem ) const override;
153 void HideItem( PNS::ITEM* aItem ) override;
154 void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
155 int aFlags = 0 ) override;
156 void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) override;
157 void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet ) override;
158 void Commit() override;
159 void AddItem( PNS::ITEM* aItem ) override;
160 void UpdateItem( PNS::ITEM* aItem ) override;
161 void RemoveItem( PNS::ITEM* aItem ) override;
162
163 int GetNetCode( PNS::NET_HANDLE aNet ) const override;
164 wxString GetNetName( PNS::NET_HANDLE aNet ) const override;
165 void UpdateNet( PNS::NET_HANDLE aNet ) override;
166
167 EDA_UNITS GetUnits() const override;
168
169 void SetCommitFlags( int aCommitFlags ) { m_commitFlags = aCommitFlags; }
170
171protected:
173 void modifyBoardItem( PNS::ITEM* aItem );
174
175 struct OFFSET
176 {
178 };
179
180 std::map<PAD*, OFFSET> m_fpOffsets;
183 std::unordered_set<BOARD_ITEM*> m_hiddenItems;
184
185 std::unordered_map<BOARD_ITEM*, EDA_GROUP*> m_itemGroups;
186 std::unordered_map<BOARD_ITEM*, std::vector<BOARD_ITEM*>> m_replacementMap;
187
189 std::unique_ptr<BOARD_COMMIT> m_commit;
191};
192
193
194#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:79
Information pertinent to a Pcbnew printed circuit board.
Definition board.h:322
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:46
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition eda_text.h:80
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition view_group.h:43
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:66
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:45
Definition pad.h:54
Base class for PNS router board items.
Definition pns_item.h:98
Keep the router "world" - i.e.
Definition pns_node.h:232
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
bool inheritTrackWidth(PNS::ITEM *aItem, int *aInheritedWidth)
void AddItem(PNS::ITEM *aItem) override
wxString GetNetName(PNS::NET_HANDLE aNet) const override
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
std::unique_ptr< PNS::ARC > syncArc(PCB_ARC *aArc)
void RemoveItem(PNS::ITEM *aItem) 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 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
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
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
void UpdateItem(PNS::ITEM *aItem) override
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, PNS::NET_HANDLE aNet, VECTOR2D aStartPosition) override
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 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
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
void modifyBoardItem(PNS::ITEM *aItem)
void Commit() override
KIGFX::VIEW_GROUP * m_previewItems
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:74
EDA_UNITS
Definition eda_units.h:48
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:33
Push and Shove diff pair dimensions (gap) settings dialog.
void * NET_HANDLE
Definition pns_item.h:55
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:695
VECTOR2< double > VECTOR2D
Definition vector2d.h:694