Horizon
Loading...
Searching...
No Matches
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
7namespace horizon {
8class Board;
9class BoardPackage;
10class BoardHole;
11class Padstack;
12class Placement;
13class Pad;
14class Track;
15class Via;
16class CanvasGL;
17class BoardJunction;
18class Junction;
19class Net;
20class BoardRules;
21class Polygon;
22class IPool;
23class Keepout;
24class KeepoutContour;
25template <typename T> class Coord;
26} // namespace horizon
27
28namespace PNS {
30public:
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
67public:
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 horizon::UUID get_via_definition_for_code(int code);
110 int get_via_definition_code(const horizon::UUID &uu);
111
112 const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Track *track);
113 const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Via *via);
114 const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardHole *hole);
115 const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
116 const PNS_HORIZON_PARENT_ITEM *get_parent(const horizon::Keepout *keepout,
117 const horizon::BoardPackage *pkg = nullptr);
118
119 int64_t get_override_routing_offset() const
120 {
121 return override_routing_offset;
122 }
123
124 void set_override_routing_offset(int64_t o)
125 {
126 override_routing_offset = o;
127 }
128
129private:
130 const PNS_HORIZON_PARENT_ITEM *get_or_create_parent(const PNS_HORIZON_PARENT_ITEM &it);
131
132 class PNS_HORIZON_RULE_RESOLVER *m_ruleResolver = nullptr;
133 std::set<horizon::ObjectRef> m_preview_items;
134
135 horizon::Board *board = nullptr;
136 class horizon::CanvasGL *canvas = nullptr;
137 const class horizon::BoardRules *rules = nullptr;
138 class horizon::IPool *pool = nullptr;
139 PNS::NODE *m_world = nullptr;
140 PNS::ROUTER *m_router = nullptr;
141
142 std::unique_ptr<PNS::SOLID> syncPad(const horizon::BoardPackage *pkg, const horizon::Pad *pad);
143 std::unique_ptr<PNS::SOLID> syncPadstack(const horizon::Padstack *padstack, const horizon::Placement &tr);
144 std::unique_ptr<PNS::SOLID> syncHole(const horizon::BoardHole *hole);
145 std::unique_ptr<PNS::SEGMENT> syncTrack(const horizon::Track *track);
146 std::unique_ptr<PNS::ARC> syncTrackArc(const horizon::Track *track);
147 std::unique_ptr<PNS::VIA> syncVia(const horizon::Via *via);
148 void syncOutline(const horizon::Polygon *poly, PNS::NODE *aWorld);
149 void syncKeepout(const horizon::KeepoutContour *keepout_contour, PNS::NODE *aWorld);
150 std::map<horizon::UUID, int> net_code_map;
151 std::vector<horizon::Net *> net_code_map_r;
152
153 std::map<horizon::UUID, int> via_definition_code_map;
154 std::vector<horizon::UUID> via_definition_code_map_r;
155
156 int64_t override_routing_offset = -1;
157
158 std::list<PNS_HORIZON_PARENT_ITEM> parents;
159
160 std::pair<horizon::BoardPackage *, horizon::Pad *> find_pad(int layer, const horizon::Coord<int64_t> &c);
161 horizon::BoardJunction *find_junction(int layer, const horizon::Coord<int64_t> &c);
162 std::set<horizon::BoardJunction *> find_junctions(const horizon::Via &via);
163 std::set<horizon::BoardJunction *> junctions_maybe_erased;
164};
165} // 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:94
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:28
Definition board.hpp:47
Definition canvas_gl.hpp:20
Your typical coordinate class.
Definition common.hpp:88
Definition ipool.hpp:15
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