Horizon
tool_helper_save_placements.hpp
1 #pragma once
2 #include <set>
3 #include "canvas/selectables.hpp"
4 #include "core/tool.hpp"
5 #include "util/placement.hpp"
6 #include <functional>
7 
8 namespace horizon {
9 class ToolHelperSavePlacements : public virtual ToolBase {
10 protected:
11  struct PlacementInfo {
12  PlacementInfo(const Coordi &c) : placement(c)
13  {
14  }
15  PlacementInfo(const Placement &p) : placement(p)
16  {
17  }
18  PlacementInfo(const Placement &p, const std::pair<Coordi, Coordi> &bbox);
19  Placement placement;
20  size_t index = 0;
21  int64_t top = 0;
22  int64_t left = 0;
23  int64_t right = 0;
24  int64_t bottom = 0;
25  };
26  std::map<SelectableRef, PlacementInfo> placements;
27  using PlacementPair = decltype(placements)::value_type;
28  void save_placements();
29  using Callback = std::function<Placement(const SelectableRef &sel, const PlacementInfo &curr)>;
30  void apply_placements(Callback fn);
31 
32  using IndexCallback = std::function<int64_t(const SelectableRef &sel, const PlacementInfo &curr)>;
33  void update_indices(IndexCallback fn);
34  const PlacementPair &get_placement_info_for_index(size_t index) const;
35  void reset_placements();
36  std::map<UUID, double> decal_scales;
37  std::map<UUID, uint64_t> picture_px_sizes;
38 
39  static bool type_is_supported(ObjectType type);
40  size_t count_types_supported() const;
41 };
42 } // namespace horizon
Definition: placement.hpp:8
Definition: selectables.hpp:34
Common interface for all Tools.
Definition: tool_pub.hpp:94
Definition: tool_helper_save_placements.hpp:9
zip_int64_t int64_t
zip_int64_t typedef.
Definition: zip.hpp:103
Definition: tool_helper_save_placements.hpp:11