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 (C) 2016-2023 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
27#include "pns_router.h"
28
31
32class BOARD;
33class BOARD_COMMIT;
34class PCB_TEXT;
36class PCB_TOOL_BASE;
37class FOOTPRINT;
38class PAD;
39class EDA_TEXT;
40
41namespace PNS
42{
43 class SIZES_SETTINGS;
44}
45
46namespace KIGFX
47{
48 class VIEW;
49}
50
52{
53public:
55 ~PNS_KICAD_IFACE_BASE() override;
56
57 void EraseView() override {};
58 void SetBoard( BOARD* aBoard );
59 void SyncWorld( PNS::NODE* aWorld ) override;
60 bool IsAnyLayerVisible( const PNS_LAYER_RANGE& aLayer ) const override { return true; };
61 bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override;
62 bool IsFlashedOnLayer( const PNS::ITEM* aItem, const PNS_LAYER_RANGE& aLayer ) const override;
63 bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; };
64 bool IsPNSCopperLayer( int aPNSLayer ) const override;
65 bool IsKicadCopperLayer( PCB_LAYER_ID aPcbnewLayer ) const;
66 void HideItem( PNS::ITEM* aItem ) override {}
67 void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
68 int aFlags = 0 ) override {}
69 void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) override {}
70 void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet ) override {}
71 void AddItem( PNS::ITEM* aItem ) override;
72 void UpdateItem( PNS::ITEM* aItem ) override;
73 void RemoveItem( PNS::ITEM* aItem ) override;
74 void Commit() override {}
75 bool ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* aStartItem, PNS::NET_HANDLE aNet,
76 VECTOR2D aStartPosition ) override;
77 int StackupHeight( int aFirstLayer, int aSecondLayer ) const override;
78
79 int GetNetCode( PNS::NET_HANDLE aNet ) const override { return -1; }
80 wxString GetNetName( PNS::NET_HANDLE aNet ) const override { return wxEmptyString; }
81 void UpdateNet( PNS::NET_HANDLE aNet ) override {}
83
85
86 PCB_LAYER_ID GetBoardLayerFromPNSLayer( int aLayer ) const override;
87 int GetPNSLayerFromBoardLayer( PCB_LAYER_ID aLayer ) const override;
88
90 void SetStartLayerFromPNS( int aLayer ) { m_startLayer = aLayer; }
91
93
94 virtual PNS::NODE* GetWorld() const override { return m_world; };
95
96 BOARD* GetBoard() const { return m_board; }
97
98 virtual EDA_UNITS GetUnits() const { return EDA_UNITS::MILLIMETRES; };
99
102
103protected:
106
107 std::vector<std::unique_ptr<PNS::SOLID>> syncPad( PAD* aPad );
108 std::unique_ptr<PNS::SEGMENT> syncTrack( PCB_TRACK* aTrack );
109 std::unique_ptr<PNS::ARC> syncArc( PCB_ARC* aArc );
110 std::unique_ptr<PNS::VIA> syncVia( PCB_VIA* aVia );
111 bool syncTextItem( PNS::NODE* aWorld, PCB_TEXT* aText, PCB_LAYER_ID aLayer );
112 bool syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aItem );
113 bool syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_SET* aBoardOutline );
114 bool inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth );
115
116protected:
119 int m_startLayer; // The starting layer, in PNS layer coordinates
120};
121
123{
124public:
126 ~PNS_KICAD_IFACE() override;
127
128 virtual void SetHostTool( PCB_TOOL_BASE* aTool );
129
130 void SetView( KIGFX::VIEW* aView );
131 void EraseView() override;
132 bool IsAnyLayerVisible( const PNS_LAYER_RANGE& aLayer ) const override;
133 bool IsItemVisible( const PNS::ITEM* aItem ) const override;
134 void HideItem( PNS::ITEM* aItem ) override;
135 void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false,
136 int aFlags = 0 ) override;
137 void DisplayPathLine( const SHAPE_LINE_CHAIN& aLine, int aImportance ) override;
138 void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, PNS::NET_HANDLE aNet ) override;
139 void Commit() override;
140 void AddItem( PNS::ITEM* aItem ) override;
141 void UpdateItem( PNS::ITEM* aItem ) override;
142 void RemoveItem( PNS::ITEM* aItem ) override;
143
144 int GetNetCode( PNS::NET_HANDLE aNet ) const override;
145 wxString GetNetName( PNS::NET_HANDLE aNet ) const override;
146 void UpdateNet( PNS::NET_HANDLE aNet ) override;
147
148 EDA_UNITS GetUnits() const override;
149
150 void SetCommitFlags( int aCommitFlags ) { m_commitFlags = aCommitFlags; }
151
152protected:
154 void modifyBoardItem( PNS::ITEM* aItem );
155
156 struct OFFSET
157 {
159 };
160
161 std::map<PAD*, OFFSET> m_fpOffsets;
164 std::unordered_set<BOARD_ITEM*> m_hiddenItems;
165
167 std::unique_ptr<BOARD_COMMIT> m_commit;
169};
170
171
172#endif
A base class derived from BOARD_ITEM for items that can be connected and have a net,...
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:79
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition: view_group.h:48
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
Definition: pad.h:54
Base class for PNS router board items.
Definition: pns_item.h:97
Keep the router "world" - i.e.
Definition: pns_node.h:231
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)
virtual PNS::NODE * GetWorld() const override
std::unique_ptr< PNS::ARC > syncArc(PCB_ARC *aArc)
void RemoveItem(PNS::ITEM *aItem) override
bool IsPNSCopperLayer(int aPNSLayer) const override
void DisplayPathLine(const SHAPE_LINE_CHAIN &aLine, int aImportance) override
PNS::RULE_RESOLVER * GetRuleResolver() override
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)
bool syncTextItem(PNS::NODE *aWorld, PCB_TEXT *aText, PCB_LAYER_ID aLayer)
int GetNetCode(PNS::NET_HANDLE aNet) const override
void HideItem(PNS::ITEM *aItem) override
void SetStartLayerFromPCBNew(PCB_LAYER_ID aLayer)
void Commit() override
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
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
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)
wxString GetNetName(PNS::NET_HANDLE aNet) const override
~PNS_KICAD_IFACE() override
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
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:73
EDA_UNITS
Definition: eda_units.h:46
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
Push and Shove diff pair dimensions (gap) settings dialog.
void * NET_HANDLE
Definition: pns_item.h:54