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) override;
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 aColor = 0, 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  bool IsAnyLayerVisible(const LAYER_RANGE &aLayer) override;
86  bool IsItemVisible(const PNS::ITEM *aItem) override;
87 
88  void UpdateNet(int aNetCode) override;
89 
90  PNS::RULE_RESOLVER *GetRuleResolver() override;
91  PNS::DEBUG_DECORATOR *GetDebugDecorator() override;
92 
93  void create_debug_decorator(horizon::CanvasGL *ca);
94 
95  static int layer_to_router(int l);
96  static int layer_from_router(int l);
97  horizon::Net *get_net_for_code(int code);
98  int get_net_code(const horizon::UUID &uu);
99 
100  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Track *track);
101  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Via *via);
102  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardHole *hole);
103  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
104  const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Keepout *keepout,
105  const horizon::BoardPackage *pkg = nullptr);
106 
107  int64_t get_override_routing_offset() const
108  {
109  return override_routing_offset;
110  }
111 
112  void set_override_routing_offset(int64_t o)
113  {
114  override_routing_offset = o;
115  }
116 
117 private:
118  const PNS_HORIZON_PARENT_ITEM *get_or_create_parent(const PNS_HORIZON_PARENT_ITEM &it);
119 
120  class PNS_HORIZON_RULE_RESOLVER *m_ruleResolver = nullptr;
121  class PNS_HORIZON_DEBUG_DECORATOR *m_debugDecorator = nullptr;
122  std::set<horizon::ObjectRef> m_preview_items;
123 
124  horizon::Board *board = nullptr;
125  class horizon::CanvasGL *canvas = nullptr;
126  const class horizon::BoardRules *rules = nullptr;
127  class horizon::IPool *pool = nullptr;
128  PNS::ROUTER *m_router;
129 
130  std::unique_ptr<PNS::SOLID> syncPad(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
131  std::unique_ptr<PNS::SOLID> syncPadstack(const horizon::Padstack *padstack, const horizon::Placement &tr);
132  std::unique_ptr<PNS::SOLID> syncHole(const horizon::BoardHole *hole);
133  std::unique_ptr<PNS::SEGMENT> syncTrack(const horizon::Track *track);
134  std::unique_ptr<PNS::VIA> syncVia(const horizon::Via *via);
135  void syncOutline(const horizon::Polygon *poly, PNS::NODE *aWorld);
136  void syncKeepout(const horizon::KeepoutContour *keepout_contour, PNS::NODE *aWorld);
137  std::map<horizon::UUID, int> net_code_map;
138  std::vector<horizon::Net *> net_code_map_r;
139 
140  int64_t override_routing_offset = -1;
141 
142  std::list<PNS_HORIZON_PARENT_ITEM> parents;
143 
144  std::pair<horizon::BoardPackage *, horizon::Pad *> find_pad(int layer, const horizon::Coord<int64_t> &c);
145  horizon::BoardJunction *find_junction(int layer, const horizon::Coord<int64_t> &c);
146  std::set<horizon::BoardJunction *> junctions_maybe_erased;
147 };
148 } // namespace PNS
Class LAYER_RANGE.
Definition: pns_layerset.h:33
Definition: pns_debug_decorator.h:33
Class ITEM.
Definition: pns_item.h:55
Class NODE.
Definition: pns_node.h:138
Definition: pns_horizon_iface.cpp:289
Definition: pns_horizon_iface.hpp:66
Definition: pns_horizon_iface.hpp:29
Definition: pns_horizon_iface.cpp:72
Class ROUTER.
Definition: pns_router.h:89
Definition: pns_router.h:113
Class RULE_RESOLVER.
Definition: pns_node.h:58
Definition: board_hole.hpp:12
Definition: board_junction.hpp:6
Definition: board_package.hpp:15
Definition: board_rules.hpp:23
Definition: board.hpp:43
Definition: canvas_gl.hpp:18
Definition: ipool.hpp:14
Definition: keepout.hpp:26
Definition: keepout.hpp:8
Definition: net.hpp:11
Definition: pad.hpp:15
Definition: padstack.hpp:21
Definition: placement.hpp:8
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition: polygon.hpp:27
Definition: track.hpp:16
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: via.hpp:16
zip_int64_t int64_t
zip_int64_t typedef.
Definition: zip.hpp:103