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 Junction;
18 class Net;
19 class BoardRules;
20 class Polygon;
21 class ViaPadstackProvider;
22 class Keepout;
23 class KeepoutContour;
24 template <typename T> class Coord;
25 } // namespace horizon
26 
27 namespace PNS {
29 public:
31  {
32  }
33  PNS_HORIZON_PARENT_ITEM(const horizon::Track *tr) : track(tr)
34  {
35  }
36  PNS_HORIZON_PARENT_ITEM(const horizon::Via *v) : via(v)
37  {
38  }
40  {
41  }
42  PNS_HORIZON_PARENT_ITEM(const horizon::BoardPackage *pkg, const horizon::Pad *p) : package(pkg), pad(p)
43  {
44  }
45  PNS_HORIZON_PARENT_ITEM(const horizon::Keepout *k) : keepout(k)
46  {
47  }
48  PNS_HORIZON_PARENT_ITEM(const horizon::Keepout *k, const horizon::BoardPackage *pkg) : package(pkg), keepout(k)
49  {
50  }
51  bool operator==(const PNS_HORIZON_PARENT_ITEM &other) const
52  {
53  return track == other.track && via == other.via && package == other.package && pad == other.pad
54  && hole == other.hole && keepout == other.keepout;
55  }
56 
57  const horizon::Track *track = nullptr;
58  const horizon::Via *via = nullptr;
59  const horizon::BoardPackage *package = nullptr;
60  const horizon::Pad *pad = nullptr;
61  const horizon::BoardHole *hole = nullptr;
62  const horizon::Keepout *keepout = nullptr;
63 };
64 
66 public:
69 
70  void SetRouter(PNS::ROUTER *aRouter) override;
71  void SetBoard(horizon::Board *brd);
72  void SetCanvas(class horizon::CanvasGL *ca);
73  void SetRules(const horizon::BoardRules *rules);
74  void SetViaPadstackProvider(horizon::ViaPadstackProvider *v);
75 
76  void SyncWorld(PNS::NODE *aWorld) override;
77  void EraseView() override;
78  void HideItem(PNS::ITEM *aItem) override;
79  void DisplayItem(const PNS::ITEM *aItem, int aColor = 0, int aClearance = 0, bool aEdit = false) override;
80  void AddItem(PNS::ITEM *aItem) override;
81  void RemoveItem(PNS::ITEM *aItem) override;
82  void Commit() override;
83 
84  bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) override;
85  bool IsItemVisible(const PNS::ITEM *aItem) override;
86 
87  void UpdateNet(int aNetCode) override;
88 
89  PNS::RULE_RESOLVER *GetRuleResolver() override;
90  PNS::DEBUG_DECORATOR *GetDebugDecorator() override;
91 
92  void create_debug_decorator(horizon::CanvasGL *ca);
93 
94  static int layer_to_router(int l);
95  static int layer_from_router(int l);
96  horizon::Net *get_net_for_code(int code);
97  int get_net_code(const horizon::UUID &uu);
98 
99  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Track *track);
100  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Via *via);
101  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardHole *hole);
102  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
103  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Keepout *keepout,
104  const horizon::BoardPackage *pkg = nullptr);
105 
106  int64_t get_override_routing_offset() const
107  {
108  return override_routing_offset;
109  }
110 
111  void set_override_routing_offset(int64_t o)
112  {
113  override_routing_offset = o;
114  }
115 
116 private:
117  const PNS_HORIZON_PARENT_ITEM *get_or_create_parent(const PNS_HORIZON_PARENT_ITEM &it);
118 
119  class PNS_HORIZON_RULE_RESOLVER *m_ruleResolver = nullptr;
120  class PNS_HORIZON_DEBUG_DECORATOR *m_debugDecorator = nullptr;
121  std::set<horizon::ObjectRef> m_preview_items;
122 
123  horizon::Board *board = nullptr;
124  class horizon::CanvasGL *canvas = nullptr;
125  const class horizon::BoardRules *rules = nullptr;
126  class horizon::ViaPadstackProvider *vpp = nullptr;
127  PNS::ROUTER *m_router;
128 
129  std::unique_ptr<PNS::SOLID> syncPad(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
130  std::unique_ptr<PNS::SOLID> syncPadstack(const horizon::Padstack *padstack, const horizon::Placement &tr);
131  std::unique_ptr<PNS::SOLID> syncHole(const horizon::BoardHole *hole);
132  std::unique_ptr<PNS::SEGMENT> syncTrack(const horizon::Track *track);
133  std::unique_ptr<PNS::VIA> syncVia(const horizon::Via *via);
134  void syncOutline(const horizon::Polygon *poly, PNS::NODE *aWorld);
135  void syncKeepout(const horizon::KeepoutContour *keepout_contour, PNS::NODE *aWorld);
136  std::map<horizon::UUID, int> net_code_map;
137  std::vector<horizon::Net *> net_code_map_r;
138 
139  int64_t override_routing_offset = -1;
140 
141  std::list<PNS_HORIZON_PARENT_ITEM> parents;
142 
143  std::pair<horizon::BoardPackage *, horizon::Pad *> find_pad(int layer, const horizon::Coord<int64_t> &c);
144  horizon::Junction *find_junction(int layer, const horizon::Coord<int64_t> &c);
145 };
146 } // namespace PNS
horizon::Polygon
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition: polygon.hpp:27
LAYER_RANGE
Class LAYER_RANGE.
Definition: pns_layerset.h:33
horizon::BoardHole
Definition: board_hole.hpp:12
PNS::PNS_HORIZON_RULE_RESOLVER
Definition: pns_horizon_iface.cpp:72
PNS::RULE_RESOLVER
Class RULE_RESOLVER.
Definition: pns_node.h:58
PNS::ROUTER
Definition: pns_router.h:113
PNS::PNS_HORIZON_DEBUG_DECORATOR
Definition: pns_horizon_iface.cpp:282
horizon::BoardRules
Definition: board_rules.hpp:22
horizon::Pad
Definition: pad.hpp:15
horizon::CanvasGL
Definition: canvas_gl.hpp:18
horizon::Board
Definition: board.hpp:42
PNS::PNS_HORIZON_PARENT_ITEM
Definition: pns_horizon_iface.hpp:28
horizon::ViaPadstackProvider
Definition: via_padstack_provider.hpp:13
horizon::Net
Definition: net.hpp:15
horizon::Keepout
Definition: keepout.hpp:9
horizon::Coord< int64_t >
libzip::int64_t
zip_int64_t int64_t
zip_int64_t typedef.
Definition: zip.hpp:103
horizon::BoardPackage
Definition: board_package.hpp:15
horizon::Padstack
Definition: padstack.hpp:21
PNS::ROUTER_IFACE
Class ROUTER.
Definition: pns_router.h:89
horizon::Track
Definition: track.hpp:16
horizon::Junction
A Junction is a point in 2D-Space.
Definition: junction.hpp:22
PNS::DEBUG_DECORATOR
Definition: pns_debug_decorator.h:33
horizon::Via
Definition: via.hpp:16
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
PNS::ITEM
Class ITEM.
Definition: pns_item.h:55
PNS::NODE
Class NODE.
Definition: pns_node.h:138
horizon::Placement
Definition: placement.hpp:8
horizon::KeepoutContour
Definition: keepout.hpp:27
PNS::PNS_HORIZON_IFACE
Definition: pns_horizon_iface.hpp:65