Horizon
core_board.hpp
1 #pragma once
2 #include "block/block.hpp"
3 #include "board/board.hpp"
4 #include "core.hpp"
5 #include "nlohmann/json.hpp"
6 #include "document/document_board.hpp"
7 #include <optional>
8 
9 namespace horizon {
10 class CoreBoard : public Core, public DocumentBoard {
11 public:
12  CoreBoard(const std::string &board_filename, const std::string &block_filename, const std::string &pictures_dir,
13  IPool &pool, IPool &pool_caching);
14 
15  class Block *get_block() override;
16  class LayerProvider &get_layer_provider() override;
17 
18  bool set_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
19  const class PropertyValue &value) override;
20  bool get_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
21  class PropertyValue &value) override;
22  bool get_property_meta(ObjectType type, const UUID &uu, ObjectProperty::ID property,
23  class PropertyMeta &meta) override;
24 
25  void rebuild(bool from_undo = false) override;
26  void reload_netlist();
27 
28  const Board &get_canvas_data();
29  Board *get_board() override;
30  const Board *get_board() const;
31 
32  class Rules *get_rules() override;
33  FabOutputSettings &get_fab_output_settings() override
34  {
35  return fab_output_settings;
36  }
37  PDFExportSettings &get_pdf_export_settings() override
38  {
39  return pdf_export_settings;
40  }
41  STEPExportSettings &get_step_export_settings() override
42  {
43  return step_export_settings;
44  }
45  PnPExportSettings &get_pnp_export_settings() override
46  {
47  return pnp_export_settings;
48  }
49 
50  BoardColors &get_colors() override
51  {
52  return colors;
53  }
54  void update_rules() override;
55 
56  std::pair<Coordi, Coordi> get_bbox() override;
57 
58  json get_meta() override;
59 
60  const std::string &get_filename() const override;
61 
62  ObjectType get_object_type() const override
63  {
64  return ObjectType::BOARD;
65  }
66 
67  const FileVersion &get_version() const override
68  {
69  return brd->version;
70  }
71 
72  void reload_pool() override;
73 
74 private:
75  std::optional<Block> block;
76  std::optional<Board> brd;
77 
78  BoardRules rules;
79  FabOutputSettings fab_output_settings;
80  PDFExportSettings pdf_export_settings;
81  STEPExportSettings step_export_settings;
82  PnPExportSettings pnp_export_settings;
83 
84  BoardColors colors;
85 
86  std::string m_board_filename;
87  std::string m_block_filename;
88  std::string m_pictures_dir;
89 
90  class HistoryItem : public Core::HistoryItem {
91  public:
92  HistoryItem(const Block &b, const Board &r);
93  Block block;
94  Board brd;
95  };
96  void history_push() override;
97  void history_load(unsigned int i) override;
98  void save(const std::string &suffix) override;
99  void delete_autosave() override;
100 };
101 } // namespace horizon
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
Definition: board.hpp:34
Definition: board_rules.hpp:22
Definition: board.hpp:42
Definition: core_board.hpp:10
json get_meta() override
Definition: core_board.cpp:671
void rebuild(bool from_undo=false) override
Expands the non-working document.
Definition: core_board.cpp:591
Definition: core.hpp:189
Where Tools and and documents meet.
Definition: core.hpp:42
Definition: document_board.hpp:14
Definition: fab_output_settings.hpp:10
Definition: file_version.hpp:8
Definition: ipool.hpp:14
Definition: layer_provider.hpp:7
Definition: pdf_export_settings.hpp:9
Definition: pnp_export_settings.hpp:11
Definition: core_properties.hpp:90
Definition: core_properties.hpp:7
Definition: rules.hpp:49
Definition: step_export_settings.hpp:10
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:170