Horizon
track.hpp
1 #pragma once
2 #include "block/net.hpp"
3 #include "board_package.hpp"
4 #include "common/common.hpp"
5 #include "board_junction.hpp"
6 #include "nlohmann/json_fwd.hpp"
7 #include "util/uuid.hpp"
8 #include "util/uuid_ptr.hpp"
9 #include <optional>
10 
11 namespace horizon {
12 using json = nlohmann::json;
13 
14 class Track {
15 public:
16  Track(const UUID &uu, const json &j, class Board *brd = nullptr);
17  Track(const UUID &uu);
18 
19  void update_refs(class Board &brd);
20  UUID get_uuid() const;
21  bool is_parallel_to(const Track &other) const;
22  double get_length() const;
23 
24  UUID uuid;
25  uuid_ptr<Net> net = nullptr;
26  int layer = 0;
27  uint64_t width = 0;
28  bool width_from_rules = true;
29 
30  bool locked = false;
31 
32  class Connection {
33  public:
34  Connection()
35  {
36  }
37  Connection(const json &j, Board *brd = nullptr);
39  Connection(BoardPackage *pkg, Pad *pad);
40  uuid_ptr<BoardJunction> junc = nullptr;
41  uuid_ptr<BoardPackage> package = nullptr;
42  uuid_ptr<Pad> pad = nullptr;
43  Coordi offset;
44  bool operator<(const Track::Connection &other) const;
45  bool operator==(const Track::Connection &other) const;
46 
47  void connect(BoardJunction *j);
48  void connect(BoardPackage *pkg, Pad *pad);
49  UUIDPath<2> get_pad_path() const;
50  bool is_junc() const;
51  bool is_pad() const;
52  void update_refs(class Board &brd);
53  Coordi get_position() const;
54  LayerRange get_layer() const;
55  Net *get_net();
56 
57  json serialize() const;
58  };
59 
60  Connection from;
61  Connection to;
62  std::optional<Coordi> center;
63  bool is_arc() const;
64 
65  json serialize() const;
66 };
67 } // namespace horizon
Definition: board_junction.hpp:6
Definition: board_package.hpp:13
Definition: board.hpp:47
Definition: layer_range.hpp:7
Definition: net.hpp:11
Definition: pad.hpp:12
Definition: track.hpp:32
Definition: track.hpp:14
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: uuid_ptr.hpp:8
a class to store JSON values
Definition: json.hpp:177
basic_json<> json
default JSON class
Definition: json_fwd.hpp:62