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
9namespace horizon {
10class CoreBoard : public Core, public DocumentBoard {
11public:
12 CoreBoard(const std::string &board_filename, const std::string &blocks_filename, const std::string &pictures_dir,
13 IPool &pool, IPool &pool_caching);
14
15 class Block *get_top_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 reload_netlist();
26
27 const Board &get_canvas_data();
28 Board *get_board() override;
29 const Board *get_board() const;
30
31 class Rules *get_rules() override;
32 GerberOutputSettings &get_gerber_output_settings() override
33 {
34 return gerber_output_settings;
35 }
36 ODBOutputSettings &get_odb_output_settings() override
37 {
38 return odb_output_settings;
39 }
40 PDFExportSettings &get_pdf_export_settings() override
41 {
42 return pdf_export_settings;
43 }
44 STEPExportSettings &get_step_export_settings() override
45 {
46 return step_export_settings;
47 }
48 PnPExportSettings &get_pnp_export_settings() override
49 {
50 return pnp_export_settings;
51 }
52 GridSettings *get_grid_settings() override
53 {
54 return &grid_settings;
55 }
56
57 BoardColors &get_colors() override
58 {
59 return colors;
60 }
61 void update_rules() override;
62
63 std::pair<Coordi, Coordi> get_bbox() override;
64
65 json get_meta() override;
66
67 const std::string &get_filename() const override;
68
69 ObjectType get_object_type() const override
70 {
71 return ObjectType::BOARD;
72 }
73
74 const FileVersion &get_version() const override
75 {
76 return brd->version;
77 }
78
79 void reload_pool() override;
80
81private:
82 std::optional<Block> block;
83 std::optional<Board> brd;
84
85 BoardRules rules;
86 GerberOutputSettings gerber_output_settings;
87 ODBOutputSettings odb_output_settings;
88 PDFExportSettings pdf_export_settings;
89 STEPExportSettings step_export_settings;
90 PnPExportSettings pnp_export_settings;
91 GridSettings grid_settings;
92
93 BoardColors colors;
94
95 std::string m_board_filename;
96 std::string m_blocks_filename;
97 std::string m_pictures_dir;
98
99 class HistoryItem : public Core::HistoryItem {
100 public:
101 HistoryItem(const Block &b, const Board &r, const std::string &comment);
102 Block block;
103 Board brd;
104 };
105 void rebuild_internal(bool from_undo, const std::string &comment) override;
106 void history_push(const std::string &comment) override;
107 void history_load(unsigned int i) override;
108 void save(const std::string &suffix) override;
109 void delete_autosave() override;
110};
111} // namespace horizon
A block is one level of hierarchy in the netlist.
Definition: block.hpp:29
Definition: board.hpp:37
Definition: board_rules.hpp:27
Definition: board.hpp:47
Definition: core_board.hpp:10
json get_meta() override
Definition: core_board.cpp:795
Definition: core.hpp:202
Where Tools and and documents meet.
Definition: core.hpp:42
Definition: document_board.hpp:14
Definition: file_version.hpp:9
Definition: gerber_output_settings.hpp:10
Definition: grid_settings.hpp:9
Definition: ipool.hpp:14
Definition: layer_provider.hpp:7
Definition: odb_output_settings.hpp:10
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:53
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:177