Horizon
pns_horizon_iface.hpp
1 #pragma once
2 #include "canvas/selectables.hpp"
3 #include "canvas/triangle.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(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) override;
80  void AddItem(PNS::ITEM *aItem) override;
81  void RemoveItem(PNS::ITEM *aItem) override;
82  void Commit() override;
83 
84  void UpdateNet(int aNetCode) override;
85 
86  PNS::RULE_RESOLVER *GetRuleResolver() override;
87  PNS::DEBUG_DECORATOR *GetDebugDecorator() override;
88 
89  void create_debug_decorator(horizon::CanvasGL *ca);
90 
91  static int layer_to_router(int l);
92  static int layer_from_router(int l);
93  horizon::Net *get_net_for_code(int code);
94  int get_net_code(const horizon::UUID &uu);
95 
96  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Track *track);
97  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Via *via);
98  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardHole *hole);
99  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
100  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Keepout *keepout,
101  const horizon::BoardPackage *pkg = nullptr);
102 
103  int64_t get_override_routing_offset() const
104  {
105  return override_routing_offset;
106  }
107 
108  void set_override_routing_offset(int64_t o)
109  {
110  override_routing_offset = o;
111  }
112 
113 private:
114  const PNS_HORIZON_PARENT_ITEM *get_or_create_parent(const PNS_HORIZON_PARENT_ITEM &it);
115 
116  class PNS_HORIZON_RULE_RESOLVER *m_ruleResolver = nullptr;
117  class PNS_HORIZON_DEBUG_DECORATOR *m_debugDecorator = nullptr;
118  std::set<horizon::ObjectRef> m_preview_items;
119 
120  horizon::Board *board = nullptr;
121  class horizon::CanvasGL *canvas = nullptr;
122  class horizon::BoardRules *rules = nullptr;
123  class horizon::ViaPadstackProvider *vpp = nullptr;
124  PNS::ROUTER *m_router;
125 
126  std::unique_ptr<PNS::SOLID> syncPad(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
127  std::unique_ptr<PNS::SOLID> syncPadstack(const horizon::Padstack *padstack, const horizon::Placement &tr);
128  std::unique_ptr<PNS::SOLID> syncHole(const horizon::BoardHole *hole);
129  std::unique_ptr<PNS::SEGMENT> syncTrack(const horizon::Track *track);
130  std::unique_ptr<PNS::VIA> syncVia(const horizon::Via *via);
131  void syncOutline(const horizon::Polygon *poly, PNS::NODE *aWorld);
132  void syncKeepout(const horizon::KeepoutContour *keepout_contour, PNS::NODE *aWorld);
133  std::map<horizon::UUID, int> net_code_map;
134  std::map<int, horizon::UUID> net_code_map_r;
135  int net_code_max = 0;
136 
137  int64_t override_routing_offset = -1;
138 
139  std::list<PNS_HORIZON_PARENT_ITEM> parents;
140 
141  std::pair<horizon::BoardPackage *, horizon::Pad *> find_pad(int layer, const horizon::Coord<int64_t> &c);
142  horizon::Junction *find_junction(int layer, const horizon::Coord<int64_t> &c);
143 };
144 } // namespace PNS
horizon::Polygon
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition: polygon.hpp:27
horizon::BoardHole
Definition: board_hole.hpp:16
PNS::PNS_HORIZON_RULE_RESOLVER
Definition: pns_horizon_iface.cpp:70
PNS::RULE_RESOLVER
Class RULE_RESOLVER.
Definition: pns_node.h:57
PNS::ROUTER
Definition: pns_router.h:109
PNS::PNS_HORIZON_DEBUG_DECORATOR
Definition: pns_horizon_iface.cpp:270
horizon::BoardRules
Definition: board_rules.hpp:20
horizon::Pad
Definition: pad.hpp:16
horizon::CanvasGL
Definition: canvas_gl.hpp:15
horizon::Board
Definition: board.hpp:31
PNS::PNS_HORIZON_PARENT_ITEM
Definition: pns_horizon_iface.hpp:28
horizon::ViaPadstackProvider
Definition: via_padstack_provider.hpp:13
horizon::Net
Definition: net.hpp:16
horizon::Keepout
Definition: keepout.hpp:9
horizon::Coord< int64_t >
horizon::BoardPackage
Definition: board_package.hpp:17
horizon::Padstack
Definition: padstack.hpp:21
PNS::ROUTER_IFACE
Class ROUTER.
Definition: pns_router.h:87
horizon::Track
Definition: track.hpp:17
horizon::Junction
A Junction is a point in 2D-Space.
Definition: junction.hpp:25
PNS::DEBUG_DECORATOR
Definition: pns_debug_decorator.h:32
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:54
libzip::int64_t
zip_int64_t int64_t
zip_int64_t typedef.
Definition: zip.hpp:103
PNS::NODE
Class NODE.
Definition: pns_node.h:136
horizon::Placement
Definition: placement.hpp:8
horizon::KeepoutContour
Definition: keepout.hpp:27
PNS::PNS_HORIZON_IFACE
Definition: pns_horizon_iface.hpp:65