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  GridSettings *get_grid_settings() override
50  {
51  return &grid_settings;
52  }
53 
54  BoardColors &get_colors() override
55  {
56  return colors;
57  }
58  void update_rules() override;
59 
60  std::pair<Coordi, Coordi> get_bbox() override;
61 
62  json get_meta() override;
63 
64  const std::string &get_filename() const override;
65 
66  ObjectType get_object_type() const override
67  {
68  return ObjectType::BOARD;
69  }
70 
71  const FileVersion &get_version() const override
72  {
73  return brd->version;
74  }
75 
76  void reload_pool() override;
77 
78 private:
79  std::optional<Block> block;
80  std::optional<Board> brd;
81 
82  BoardRules rules;
83  FabOutputSettings fab_output_settings;
84  PDFExportSettings pdf_export_settings;
85  STEPExportSettings step_export_settings;
86  PnPExportSettings pnp_export_settings;
87  GridSettings grid_settings;
88 
89  BoardColors colors;
90 
91  std::string m_board_filename;
92  std::string m_block_filename;
93  std::string m_pictures_dir;
94 
95  class HistoryItem : public Core::HistoryItem {
96  public:
97  HistoryItem(const Block &b, const Board &r);
98  Block block;
99  Board brd;
100  };
101  void history_push() override;
102  void history_load(unsigned int i) override;
103  void save(const std::string &suffix) override;
104  void delete_autosave() override;
105 };
106 } // namespace horizon
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
Definition: board.hpp:35
Definition: board_rules.hpp:22
Definition: board.hpp:43
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:194
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: grid_settings.hpp:9
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