Horizon
tool_add_vertex.hpp
1 #pragma once
2 #include "common/polygon.hpp"
3 #include "core/tool.hpp"
4 #include <forward_list>
5 
6 namespace horizon {
7 
8 class ToolAddVertex : public ToolBase {
9 public:
10  ToolAddVertex(IDocument *c, ToolID tid);
11  ToolResponse begin(const ToolArgs &args) override;
12  ToolResponse update(const ToolArgs &args) override;
13  bool can_begin() override;
14  bool is_specific() override
15  {
16  return true;
17  }
18  std::set<InToolActionID> get_actions() const override
19  {
20  using I = InToolActionID;
21  return {
22  I::LMB,
23  I::CANCEL,
24  I::RMB,
25  I::FLIP_DIRECTION,
26  };
27  }
28 
29 private:
30  Polygon *poly = nullptr;
31  Polygon::Vertex *vertex = nullptr;
32  int vertex_index = 0;
33  unsigned int n_vertices_placed = 0;
34  bool flip_direction = false;
35  void update_tip();
36  void add_vertex(const Coordi &c);
37 };
38 } // namespace horizon
horizon::IDocument
Definition: idocument.hpp:5
horizon::ToolAddVertex::is_specific
bool is_specific() override
Definition: tool_add_vertex.hpp:14
horizon::ToolAddVertex::can_begin
bool can_begin() override
Definition: tool_add_vertex.cpp:12
horizon::ToolBase
Common interface for all Tools.
Definition: tool.hpp:121
horizon::ToolAddVertex
Definition: tool_add_vertex.hpp:8
horizon::ToolAddVertex::update
ToolResponse update(const ToolArgs &args) override
Gets called whenever the user generated some sort of input.
Definition: tool_add_vertex.cpp:60
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
horizon::ToolAddVertex::begin
ToolResponse begin(const ToolArgs &args) override
Gets called right after the constructor has finished.
Definition: tool_add_vertex.cpp:31