Horizon
pns_horizon_iface.hpp
1 #pragma once
2 #include "canvas/selectables.hpp"
3 #include "canvas/object_ref.hpp"
4 #include "router/pns_router.h"
5 #include "util/uuid.hpp"
6 
7 namespace horizon {
8 class Board;
9 class BoardPackage;
10 class BoardHole;
11 class Padstack;
12 class Placement;
13 class Pad;
14 class Track;
15 class Via;
16 class CanvasGL;
17 class BoardJunction;
18 class Junction;
19 class Net;
20 class BoardRules;
21 class Polygon;
22 class IPool;
23 class Keepout;
24 class KeepoutContour;
25 template <typename T> class Coord;
26 } // namespace horizon
27 
28 namespace PNS {
30 public:
32  {
33  }
34  PNS_HORIZON_PARENT_ITEM(const horizon::Track *tr) : track(tr)
35  {
36  }
37  PNS_HORIZON_PARENT_ITEM(const horizon::Via *v) : via(v)
38  {
39  }
41  {
42  }
43  PNS_HORIZON_PARENT_ITEM(const horizon::BoardPackage *pkg, const horizon::Pad *p) : package(pkg), pad(p)
44  {
45  }
46  PNS_HORIZON_PARENT_ITEM(const horizon::Keepout *k) : keepout(k)
47  {
48  }
49  PNS_HORIZON_PARENT_ITEM(const horizon::Keepout *k, const horizon::BoardPackage *pkg) : package(pkg), keepout(k)
50  {
51  }
52  bool operator==(const PNS_HORIZON_PARENT_ITEM &other) const
53  {
54  return track == other.track && via == other.via && package == other.package && pad == other.pad
55  && hole == other.hole && keepout == other.keepout;
56  }
57 
58  const horizon::Track *track = nullptr;
59  const horizon::Via *via = nullptr;
60  const horizon::BoardPackage *package = nullptr;
61  const horizon::Pad *pad = nullptr;
62  const horizon::BoardHole *hole = nullptr;
63  const horizon::Keepout *keepout = nullptr;
64 };
65 
67 public:
70 
71  void SetRouter(PNS::ROUTER *aRouter);
72  void SetBoard(horizon::Board *brd);
73  void SetCanvas(class horizon::CanvasGL *ca);
74  void SetRules(const horizon::BoardRules *rules);
75  void SetPool(horizon::IPool *pool);
76 
77  void SyncWorld(PNS::NODE *aWorld) override;
78  void EraseView() override;
79  void HideItem(PNS::ITEM *aItem) override;
80  void DisplayItem(const PNS::ITEM *aItem, int aClearance = 0, bool aEdit = false) override;
81  void AddItem(PNS::ITEM *aItem) override;
82  void RemoveItem(PNS::ITEM *aItem) override;
83  void Commit() override;
84 
85  void UpdateItem(ITEM *aItem) override;
86  bool IsFlashedOnLayer(const PNS::ITEM *aItem, int aLayer) const override;
87  bool ImportSizes(SIZES_SETTINGS &aSizes, ITEM *aStartItem, int aNet) override;
88  int StackupHeight(int aFirstLayer, int aSecondLayer) const override;
89  void DisplayRatline(const SHAPE_LINE_CHAIN &aRatline, int aColor = -1) override;
90 
91  PNS::NODE *GetWorld() const override
92  {
93  return m_world;
94  }
95 
96  bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) const override;
97  bool IsItemVisible(const PNS::ITEM *aItem) const override;
98 
99  void UpdateNet(int aNetCode) override;
100 
101  PNS::RULE_RESOLVER *GetRuleResolver() override;
102  PNS::DEBUG_DECORATOR *GetDebugDecorator() override;
103 
104  static int layer_to_router(int l);
105  static int layer_from_router(int l);
106  horizon::Net *get_net_for_code(int code);
107  int get_net_code(const horizon::UUID &uu);
108 
109  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Track *track);
110  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Via *via);
111  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardHole *hole);
112  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
113  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Keepout *keepout,
114  const horizon::BoardPackage *pkg = nullptr);
115 
116  int64_t get_override_routing_offset() const
117  {
118  return override_routing_offset;
119  }
120 
121  void set_override_routing_offset(int64_t o)
122  {
123  override_routing_offset = o;
124  }
125 
126 private:
127  const PNS_HORIZON_PARENT_ITEM *get_or_create_parent(const PNS_HORIZON_PARENT_ITEM &it);
128 
129  class PNS_HORIZON_RULE_RESOLVER *m_ruleResolver = nullptr;
130  std::set<horizon::ObjectRef> m_preview_items;
131 
132  horizon::Board *board = nullptr;
133  class horizon::CanvasGL *canvas = nullptr;
134  const class horizon::BoardRules *rules = nullptr;
135  class horizon::IPool *pool = nullptr;
136  PNS::NODE *m_world = nullptr;
137  PNS::ROUTER *m_router = nullptr;
138 
139  std::unique_ptr<PNS::SOLID> syncPad(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
140  std::unique_ptr<PNS::SOLID> syncPadstack(const horizon::Padstack *padstack, const horizon::Placement &tr);
141  std::unique_ptr<PNS::SOLID> syncHole(const horizon::BoardHole *hole);
142  std::unique_ptr<PNS::SEGMENT> syncTrack(const horizon::Track *track);
143  std::unique_ptr<PNS::ARC> syncTrackArc(const horizon::Track *track);
144  std::unique_ptr<PNS::VIA> syncVia(const horizon::Via *via);
145  void syncOutline(const horizon::Polygon *poly, PNS::NODE *aWorld);
146  void syncKeepout(const horizon::KeepoutContour *keepout_contour, PNS::NODE *aWorld);
147  std::map<horizon::UUID, int> net_code_map;
148  std::vector<horizon::Net *> net_code_map_r;
149 
150  int64_t override_routing_offset = -1;
151 
152  std::list<PNS_HORIZON_PARENT_ITEM> parents;
153 
154  std::pair<horizon::BoardPackage *, horizon::Pad *> find_pad(int layer, const horizon::Coord<int64_t> &c);
155  horizon::BoardJunction *find_junction(int layer, const horizon::Coord<int64_t> &c);
156  std::set<horizon::BoardJunction *> find_junctions(const horizon::Coord<int64_t> &c);
157  std::set<horizon::BoardJunction *> junctions_maybe_erased;
158 };
159 } // namespace PNS
Represent a contiguous set of PCB layers.
Definition: pns_layerset.h:32
Definition: pns_debug_decorator.h:35
Base class for PNS router board items.
Definition: pns_item.h:57
Keep the router "world" - i.e.
Definition: pns_node.h:148
Definition: pns_horizon_iface.hpp:66
Definition: pns_horizon_iface.hpp:29
Definition: pns_horizon_iface.cpp:74
ROUTER.
Definition: pns_router.h:87
Definition: pns_router.h:116
Definition: pns_node.h:79
Definition: pns_sizes_settings.h:42
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Definition: shape_line_chain.h:81
Definition: board_hole.hpp:12
Definition: board_junction.hpp:6
Definition: board_package.hpp:13
Definition: board_rules.hpp:27
Definition: board.hpp:47
Definition: canvas_gl.hpp:20
Definition: ipool.hpp:14
Definition: keepout.hpp:26
Definition: keepout.hpp:8
Definition: net.hpp:11
Definition: pad.hpp:12
Definition: padstack.hpp:19
Definition: placement.hpp:8
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition: polygon.hpp:25
Definition: track.hpp:14
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: via.hpp:12