Horizon
canvas_patch.hpp
1#pragma once
2#include "canvas.hpp"
3#include "clipper/clipper.hpp"
4
5namespace horizon {
6class CanvasPatch : public Canvas {
7public:
8 class PatchKey {
9 public:
10 PatchType type;
11 int layer;
12 UUID net;
13 bool operator<(const PatchKey &other) const
14 {
15 if (type < other.type)
16 return true;
17 else if (type > other.type)
18 return false;
19
20 if (layer < other.layer)
21 return true;
22 else if (layer > other.layer)
23 return false;
24
25 return net < other.net;
26 }
27 };
28
29 const std::map<PatchKey, ClipperLib::Paths> &get_patches() const;
30 const std::set<std::tuple<int, Coordi, Coordi>> &get_text_extents() const;
31 void clear() override;
32
33 void append_polygon(const Polygon &poly);
34
35 enum class SimplifyOnUpdate { YES, NO };
36 CanvasPatch(SimplifyOnUpdate simplify_on_update = SimplifyOnUpdate::YES);
37
38 void push() override
39 {
40 }
41 void request_push() override;
42 void simplify();
43
44private:
45 const SimplifyOnUpdate simplify_on_update;
46 const Net *net = nullptr;
47 PatchType patch_type = PatchType::OTHER;
48 virtual void img_net(const Net *net) override;
49 virtual void img_polygon(const Polygon &poly, bool tr) override;
50 virtual void img_hole(const class Hole &hole) override;
51 virtual void img_patch_type(PatchType type) override;
52
53 std::map<PatchKey, ClipperLib::Paths> patches;
54 std::set<std::tuple<int, Coordi, Coordi>> text_extents;
55};
56} // namespace horizon
Definition: canvas_patch.hpp:8
Definition: canvas_patch.hpp:6
Definition: canvas.hpp:24
Polygon used in Padstack, Package and Board for specifying filled Regions.
Definition: polygon.hpp:25
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16