Horizon
Loading...
Searching...
No Matches
canvas_patch.hpp
1#pragma once
2#include "canvas.hpp"
3#include "clipper/clipper.hpp"
4#include "util/layer_range.hpp"
5
6namespace horizon {
7class CanvasPatch : public Canvas {
8public:
9 class PatchKey {
10 public:
11 PatchType type;
12 LayerRange layer;
13 UUID net;
14 bool operator<(const PatchKey &other) const
15 {
16 if (type < other.type)
17 return true;
18 else if (type > other.type)
19 return false;
20
21 if (layer < other.layer)
22 return true;
23 else if (layer > other.layer)
24 return false;
25
26 return net < other.net;
27 }
28 };
29
30 const std::map<PatchKey, ClipperLib::Paths> &get_patches() const;
31 const std::set<std::tuple<int, Coordi, Coordi>> &get_text_extents() const;
32 void clear() override;
33
34 void append_polygon(const Polygon &poly);
35
36 enum class SimplifyOnUpdate { YES, NO };
37 CanvasPatch(SimplifyOnUpdate simplify_on_update = SimplifyOnUpdate::YES);
38
39 void push() override
40 {
41 }
42 void request_push() override;
43 void simplify();
44
45private:
46 const SimplifyOnUpdate simplify_on_update;
47 const Net *net = nullptr;
48 PatchType patch_type = PatchType::OTHER;
49 virtual void img_net(const Net *net) override;
50 virtual void img_polygon(const Polygon &poly, bool tr) override;
51 virtual void img_polygon(const Polygon &poly, bool tr, const LayerRange &layer);
52 virtual void img_hole(const class Hole &hole) override;
53 virtual void img_patch_type(PatchType type) override;
54
55 std::map<PatchKey, ClipperLib::Paths> patches;
56 std::set<std::tuple<int, Coordi, Coordi>> text_extents;
57};
58} // namespace horizon
Definition canvas_patch.hpp:9
Definition canvas_patch.hpp:7
Definition canvas.hpp:25
Definition layer_range.hpp:11
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