Horizon
tool_map_pin.hpp
1 #pragma once
2 #include "core/tool.hpp"
3 
4 namespace horizon {
5 class ToolMapPin : public ToolBase {
6 public:
7  using ToolBase::ToolBase;
8  ToolResponse begin(const ToolArgs &args) override;
9  ToolResponse update(const ToolArgs &args) override;
10  bool can_begin() override;
11  ~ToolMapPin();
12  std::set<InToolActionID> get_actions() const override
13  {
14  using I = InToolActionID;
15  return {
16  I::LMB, I::CANCEL, I::RMB, I::ROTATE, I::MIRROR, I::EDIT, I::AUTOPLACE_ALL_PINS, I::AUTOPLACE_NEXT_PIN,
17  };
18  }
19 
20  class Settings : public ToolSettings {
21  public:
22  json serialize() const override;
23  void load_from_json(const json &j) override;
24  Orientation orientation = Orientation::RIGHT;
25  };
26 
27  ToolSettings *get_settings() override
28  {
29  return &settings;
30  }
31 
32 private:
33  Settings settings;
34 
35  std::vector<std::pair<const class Pin *, bool>> pins;
36  std::optional<UUID> map_pin_dialog();
37  unsigned int pin_index = 0;
38  class SymbolPin *pin = nullptr;
39  SymbolPin *pin_last = nullptr;
40  SymbolPin *pin_last2 = nullptr;
41  void create_pin(const UUID &uu);
42  bool can_autoplace() const;
43  void update_tip();
44  class CanvasAnnotation *annotation = nullptr;
45  void update_annotation();
46 };
47 } // namespace horizon
Definition: annotation.hpp:7
Definition: symbol.hpp:20
This is what a Tool receives when the user did something.
Definition: tool_pub.hpp:23
Common interface for all Tools.
Definition: tool_pub.hpp:94
Definition: tool_map_pin.hpp:20
Definition: tool_map_pin.hpp:5
ToolResponse update(const ToolArgs &args) override
Gets called whenever the user generated some sort of input.
Definition: tool_map_pin.cpp:156
ToolResponse begin(const ToolArgs &args) override
Gets called right after the constructor has finished.
Definition: tool_map_pin.cpp:42
bool can_begin() override
Definition: tool_map_pin.cpp:13
To signal back to the core what the Tool did, a Tool returns a ToolResponse.
Definition: tool_pub.hpp:40
Definition: tool_pub.hpp:82
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
a class to store JSON values
Definition: json.hpp:177