Horizon
Loading...
Searching...
No Matches
padstack.hpp
1#pragma once
2#include "common/common.hpp"
3#include "common/hole.hpp"
4#include "common/layer_provider.hpp"
5#include "common/lut.hpp"
6#include "common/polygon.hpp"
7#include "common/shape.hpp"
8#include "nlohmann/json_fwd.hpp"
9#include "parameter/program.hpp"
10#include "parameter/program_polygon.hpp"
11#include "util/uuid.hpp"
12#include <map>
13#include <set>
14#include "util/file_version.hpp"
15
16namespace horizon {
17using json = nlohmann::json;
18
19class Padstack : public LayerProvider {
20public:
22 friend Padstack;
23
24 protected:
25 std::map<UUID, Polygon> &get_polygons() override;
26
27 private:
28 ParameterProgram::CommandHandler get_command(const std::string &cmd) override;
29 class Padstack *ps = nullptr;
30
31 std::optional<std::string> set_shape(const TokenCommand &cmd);
32 std::optional<std::string> set_hole(const TokenCommand &cmd);
33
34 public:
35 MyParameterProgram(class Padstack *p, const std::string &code);
36 };
37
38 enum class Type { TOP, BOTTOM, THROUGH, VIA, HOLE, MECHANICAL };
39 static const LutEnumStr<Padstack::Type> type_lut;
40
41 Padstack(const UUID &uu, const json &j);
42 Padstack(const UUID &uu);
43 static Padstack new_from_file(const std::string &filename);
44 static unsigned int get_app_version();
45
46 json serialize() const;
47
48 Padstack(const Padstack &ps);
49 void operator=(Padstack const &ps);
50
51 UUID uuid;
52 std::string name;
53 std::string well_known_name;
54 Type type = Type::TOP;
55 std::map<UUID, Polygon> polygons;
56 std::map<UUID, Hole> holes;
57 std::map<UUID, Shape> shapes;
58
59 ParameterSet parameter_set;
60 std::set<ParameterID> parameters_required;
61 MyParameterProgram parameter_program;
62
63 FileVersion version;
64
65 std::optional<std::string> apply_parameter_set(const ParameterSet &ps);
66
67 UUID get_uuid() const;
68 std::pair<Coordi, Coordi> get_bbox(bool copper_only = false) const;
69 void expand_inner(unsigned int n_inner, const class LayerRange &span);
70 const std::map<int, Layer> &get_layers() const override;
71
72private:
73 void update_refs();
74};
75} // namespace horizon
Definition pgm-test.cpp:7
Definition file_version.hpp:9
Definition layer_provider.hpp:8
Definition layer_range.hpp:11
Definition lut.hpp:18
Definition padstack.hpp:21
Definition padstack.hpp:19
Definition program_polygon.hpp:8
This class encapsulates a UUID and allows it to be uses as a value type.
Definition uuid.hpp:16
a class to store JSON values
Definition json.hpp:177
basic_json<> json
default JSON class
Definition json_fwd.hpp:62