1 #pragma once
2 #include "core/tool.hpp"
3 #include "tool_settings_rectangle_mode.hpp"
4 
5 namespace horizon {
6 
7 class ToolDrawPolygonRectangle : public ToolBase {
8 public:
9     using ToolBase::ToolBase;
10     ToolResponse begin(const ToolArgs &args) override;
11     ToolResponse update(const ToolArgs &args) override;
12     bool can_begin() override;
13 
get_settings()14     ToolSettings *get_settings() override
15     {
16         return &settings;
17     }
18 
19     void apply_settings() override;
20 
get_actions() const21     std::set<InToolActionID> get_actions() const override
22     {
23         using I = InToolActionID;
24         return {
25                 I::LMB,
26                 I::CANCEL,
27                 I::RMB,
28                 I::RECTANGLE_MODE,
29                 I::POLYGON_CORNER_RADIUS,
30                 I::POLYGON_DECORATION_POSITION,
31                 I::POLYGON_DECORATION_SIZE,
32                 I::POLYGON_DECORATION_STYLE,
33         };
34     }
35 
36 private:
37     ToolSettingsRectangleMode settings;
38     using Mode = ToolSettingsRectangleMode::Mode;
39 
40     enum class Decoration { NONE, CHAMFER, NOTCH };
41 
42     Decoration decoration = Decoration::NONE;
43     int decoration_pos = 0;
44     Coordi first_pos;
45     Coordi second_pos;
46     int step = 0;
47     uint64_t decoration_size = 1.2_mm;
48     int64_t corner_radius = 0;
49 
50     class Polygon *temp = nullptr;
51 
52     void update_polygon();
53     void update_tip();
54 };
55 } // namespace horizon
56