KiCad PCB EDA Suite
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-2021 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 
32 class BOARD;
33 class BOARD_COMMIT;
35 class PCB_TOOL_BASE;
36 class FOOTPRINT;
37 class PAD;
38 
39 namespace PNS
40 {
41  class SIZES_SETTINGS;
42 }
43 
44 namespace KIGFX
45 {
46  class VIEW;
47 }
48 
50 {
51 public:
54 
55  void EraseView() override {};
56  void SetBoard( BOARD* aBoard );
57  void SyncWorld( PNS::NODE* aWorld ) override;
58  bool IsAnyLayerVisible( const LAYER_RANGE& aLayer ) const override { return true; };
59  bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override { return true; };
60  bool IsItemVisible( const PNS::ITEM* aItem ) const override { return true; }
61  void HideItem( PNS::ITEM* aItem ) override {}
62  void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override {}
63  void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) override {}
64  void AddItem( PNS::ITEM* aItem ) override;
65  void UpdateItem( PNS::ITEM* aItem ) override;
66  void RemoveItem( PNS::ITEM* aItem ) override;
67  void Commit() override {}
68  bool ImportSizes( PNS::SIZES_SETTINGS& aSizes, PNS::ITEM* aStartItem, int aNet ) override;
69  int StackupHeight( int aFirstLayer, int aSecondLayer ) const override;
70 
71  void UpdateNet( int aNetCode ) override {}
72 
74 
75  void SetStartLayer( int aLayer ) { m_startLayer = aLayer; }
76 
77  virtual PNS::NODE* GetWorld() const override
78  {
79  return m_world;
80  };
81 
82  BOARD* GetBoard() const
83  {
84  return m_board;
85  }
86 
89 
90 protected:
93 
94  std::unique_ptr<PNS::SOLID> syncPad( PAD* aPad );
95  std::unique_ptr<PNS::SEGMENT> syncTrack( PCB_TRACK* aTrack );
96  std::unique_ptr<PNS::ARC> syncArc( PCB_ARC* aArc );
97  std::unique_ptr<PNS::VIA> syncVia( PCB_VIA* aVia );
98  bool syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB_LAYER_ID aLayer );
99  bool syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aItem );
100  bool syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_SET* aBoardOutline );
101  bool inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth );
102 
103 protected:
107 };
108 
110 {
111 public:
112  PNS_KICAD_IFACE();
114 
115  void SetHostTool( PCB_TOOL_BASE* aTool );
116  void SetDisplayOptions( const PCB_DISPLAY_OPTIONS* aDispOptions );
117 
118  void SetView( KIGFX::VIEW* aView );
119  void EraseView() override;
120  bool IsAnyLayerVisible( const LAYER_RANGE& aLayer ) const override;
121  bool IsItemVisible( const PNS::ITEM* aItem ) const override;
122  bool IsFlashedOnLayer( const PNS::ITEM* aItem, int aLayer ) const override;
123  void HideItem( PNS::ITEM* aItem ) override;
124  void DisplayItem( const PNS::ITEM* aItem, int aClearance, bool aEdit = false ) override;
125  void DisplayRatline( const SHAPE_LINE_CHAIN& aRatline, int aColor = -1 ) override;
126  void Commit() override;
127  void AddItem( PNS::ITEM* aItem ) override;
128  void UpdateItem( PNS::ITEM* aItem ) override;
129  void RemoveItem( PNS::ITEM* aItem ) override;
130 
131  void UpdateNet( int aNetCode ) override;
132 
133 
134 private:
135  struct OFFSET
136  {
138  };
139 
140  std::map<PAD*, OFFSET> m_fpOffsets;
143  std::unordered_set<BOARD_ITEM*> m_hiddenItems;
144 
146  std::unique_ptr<BOARD_COMMIT> m_commit;
148 };
149 
150 
151 #endif
void SetHostTool(PCB_TOOL_BASE *aTool)
Base class for PNS router board items.
Definition: pns_item.h:55
void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, int aColor=-1) override
bool syncTextItem(PNS::NODE *aWorld, EDA_TEXT *aText, PCB_LAYER_ID aLayer)
BOARD * GetBoard() const
void SetView(KIGFX::VIEW *aView)
void SetStartLayer(int aLayer)
void DisplayItem(const PNS::ITEM *aItem, int aClearance, bool aEdit=false) override
std::unique_ptr< PNS::SEGMENT > syncTrack(PCB_TRACK *aTrack)
PNS::RULE_RESOLVER * GetRuleResolver() override
Keep the router "world" - i.e.
Definition: pns_node.h:146
bool syncGraphicalItem(PNS::NODE *aWorld, PCB_SHAPE *aItem)
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:236
void UpdateItem(PNS::ITEM *aItem) override
bool inheritTrackWidth(PNS::ITEM *aItem, int *aInheritedWidth)
PNS::DEBUG_DECORATOR * m_debugDecorator
void UpdateNet(int aNetCode) override
bool IsItemVisible(const PNS::ITEM *aItem) const override
void SetDebugDecorator(PNS::DEBUG_DECORATOR *aDec)
void HideItem(PNS::ITEM *aItem) override
std::unordered_set< BOARD_ITEM * > m_hiddenItems
void DisplayItem(const PNS::ITEM *aItem, int aClearance, bool aEdit=false) override
A mix-in class (via multiple inheritance) that handles texts such as labels, parts,...
Definition: eda_text.h:140
Container for display options like enable/disable some optional drawings.
void Commit() override
void UpdateNet(int aNetCode) override
std::unique_ptr< PNS::VIA > syncVia(PCB_VIA *aVia)
Represent a set of closed polygons.
void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, int aColor=-1) override
std::unique_ptr< BOARD_COMMIT > m_commit
bool IsItemVisible(const PNS::ITEM *aItem) const override
virtual PNS::NODE * GetWorld() const override
PNS::DEBUG_DECORATOR * GetDebugDecorator() override
bool IsFlashedOnLayer(const PNS::ITEM *aItem, int aLayer) const override
std::unique_ptr< PNS::ARC > syncArc(PCB_ARC *aArc)
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition: view_group.h:46
KIGFX::VIEW_GROUP * m_previewItems
void UpdateItem(PNS::ITEM *aItem) override
Handle a list of polygons defining a copper zone.
Definition: zone.h:56
void SyncWorld(PNS::NODE *aWorld) override
int StackupHeight(int aFirstLayer, int aSecondLayer) const override
void AddItem(PNS::ITEM *aItem) override
const PCB_DISPLAY_OPTIONS * m_dispOptions
void Commit() override
void SetBoard(BOARD *aBoard)
void EraseView() override
KIGFX::VIEW * m_view
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:191
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void RemoveItem(PNS::ITEM *aItem) override
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:65
void AddItem(PNS::ITEM *aItem) override
PCB_TOOL_BASE * m_tool
void EraseView() override
bool IsFlashedOnLayer(const PNS::ITEM *aItem, int aLayer) const override
PNS_PCBNEW_RULE_RESOLVER * m_ruleResolver
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:57
Push and Shove diff pair dimensions (gap) settings dialog.
bool ImportSizes(PNS::SIZES_SETTINGS &aSizes, PNS::ITEM *aStartItem, int aNet) override
void SetDisplayOptions(const PCB_DISPLAY_OPTIONS *aDispOptions)
std::map< PAD *, OFFSET > m_fpOffsets
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:31
void RemoveItem(PNS::ITEM *aItem) override
std::unique_ptr< PNS::SOLID > syncPad(PAD *aPad)
bool syncZone(PNS::NODE *aWorld, ZONE *aZone, SHAPE_POLY_SET *aBoardOutline)
void HideItem(PNS::ITEM *aItem) override
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) const override
bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) const override