Horizon
tool_draw_polygon.hpp
1 #pragma once
2 #include "common/polygon.hpp"
3 #include "core/tool.hpp"
4 #include "tool_helper_restrict.hpp"
5 
6 namespace horizon {
7 
8 class ToolDrawPolygon : public ToolBase, public ToolHelperRestrict {
9 public:
10  ToolDrawPolygon(IDocument *c, ToolID tid);
11  ToolResponse begin(const ToolArgs &args) override;
12  ToolResponse update(const ToolArgs &args) override;
13  bool can_begin() override;
14  std::set<InToolActionID> get_actions() const override
15  {
16  using I = InToolActionID;
17  return {
18  I::LMB, I::CANCEL, I::RMB, I::FLIP_ARC, I::TOGGLE_ARC, I::RESTRICT,
19  };
20  }
21 
22 private:
23  Polygon *temp = nullptr;
24  Polygon::Vertex *vertex = nullptr;
25  Polygon::Vertex *last_vertex = nullptr;
26  enum class ArcMode { OFF, NEXT, CURRENT };
27  ArcMode arc_mode = ArcMode::OFF;
28  void update_tip();
29  void update_vertex(const Coordi &c);
30  void set_snap_filter();
31 };
32 } // namespace horizon
horizon::ToolDrawPolygon::begin
ToolResponse begin(const ToolArgs &args) override
Gets called right after the constructor has finished.
horizon::ToolDrawPolygon::can_begin
bool can_begin() override
horizon::ToolDrawPolygon::update
ToolResponse update(const ToolArgs &args) override
Gets called whenever the user generated some sort of input.
horizon::ToolResponse
To signal back to the core what the Tool did, a Tool returns a ToolResponse.
Definition: tool.hpp:42
horizon::ToolArgs
This is what a Tool receives when the user did something.
Definition: tool.hpp:23