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