Horizon
core_schematic.hpp
1 #pragma once
2 #include "blocks/blocks_schematic.hpp"
3 #include "core.hpp"
4 #include "document/idocument_schematic.hpp"
5 #include "document/idocument_block_symbol.hpp"
6 #include "schematic/iinstancce_mapping_provider.hpp"
7 #include <memory>
8 #include <optional>
9 
10 namespace horizon {
11 class CoreSchematic : public Core,
12  public virtual IDocumentSchematic,
13  public virtual IDocumentBlockSymbol,
15 public:
16  CoreSchematic(const std::string &blocks_filename, const std::string &pictures_dir, IPool &pool,
17  IPool &pool_caching);
18  bool has_object_type(ObjectType ty) const override;
19 
20  Schematic *get_current_schematic() override;
21  const Schematic *get_current_schematic() const;
22  Schematic *get_top_schematic() override;
23  const Schematic *get_top_schematic() const;
24  Sheet *get_sheet() override;
25  const Sheet *get_sheet() const;
26 
27  BlockSymbol &get_block_symbol() override;
28 
29  Junction *get_junction(const UUID &uu) override;
30  Junction *insert_junction(const UUID &uu) override;
31  void delete_junction(const UUID &uu) override;
32 
33  class Block *get_top_block() override;
34  const Block *get_top_block() const;
35  class Block *get_current_block() override;
36  const Block *get_current_block() const;
37  class LayerProvider &get_layer_provider() override;
38 
39  bool set_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
40  const class PropertyValue &value) override;
41  bool get_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
42  class PropertyValue &value) override;
43  bool get_property_meta(ObjectType type, const UUID &uu, ObjectProperty::ID property,
44  class PropertyMeta &meta) override;
45 
46  std::string get_display_name(ObjectType type, const UUID &uu) override;
47  std::string get_display_name(ObjectType type, const UUID &uu, const UUID &sheet) override;
48 
49  class Rules *get_rules() override;
50 
51  BOMExportSettings *get_bom_export_settings()
52  {
53  return &bom_export_settings;
54  }
55 
56  PDFExportSettings *get_pdf_export_settings()
57  {
58  return &pdf_export_settings;
59  }
60 
61  void add_sheet();
62  void delete_sheet(const UUID &uu);
63 
64  void set_sheet(const UUID &uu);
65  const Sheet &get_canvas_data();
66  const BlockSymbol &get_canvas_data_block_symbol();
67  std::pair<Coordi, Coordi> get_bbox() override;
68 
69  void set_block(const UUID &uu);
70  const UUID &get_current_block_uuid() const;
71  const UUID &get_top_block_uuid() const;
72 
73  void set_block_symbol_mode();
74  bool get_block_symbol_mode() const override;
75 
76  const BlocksSchematic &get_blocks() const;
77  BlocksSchematic &get_blocks() override;
78  bool current_block_is_top() const override;
79 
80  void set_instance_path(const UUIDVec &path);
81  const UUIDVec &get_instance_path() const override;
82  bool in_hierarchy() const override;
83 
84  const BlockInstanceMapping *get_block_instance_mapping() const override;
85  BlockInstanceMapping *get_block_instance_mapping();
86 
87  unsigned int get_sheet_index(const class UUID &sheet) const override;
88  unsigned int get_sheet_total() const override;
89  unsigned int get_sheet_index_for_path(const class UUID &sheet, const UUIDVec &path) const;
90 
91  Schematic &get_schematic_for_instance_path(const UUIDVec &path) override;
92 
93  const std::string &get_filename() const override;
94 
95  ObjectType get_object_type() const override
96  {
97  return ObjectType::SCHEMATIC;
98  }
99 
100  const FileVersion &get_version() const override
101  {
102  return get_top_schematic()->version;
103  }
104 
105  void reload_pool() override;
106 
107 private:
108  std::map<UUID, Line> *get_line_map() override;
109  std::map<UUID, Arc> *get_arc_map() override;
110  std::map<UUID, Text> *get_text_map() override;
111  std::map<UUID, Picture> *get_picture_map() override;
112 
113  std::optional<BlocksSchematic> blocks;
114 
115  SchematicRules rules;
116 
117  BOMExportSettings bom_export_settings;
118  PDFExportSettings pdf_export_settings;
119 
120  UUID sheet_uuid;
121  UUID block_uuid;
122  UUIDVec instance_path;
123 
124  std::string m_blocks_filename;
125  std::string m_pictures_dir;
126 
127  class HistoryItem : public Core::HistoryItem {
128  public:
129  HistoryItem(const BlocksSchematic &bl, const std::string &cm) : Core::HistoryItem(cm), blocks(bl)
130  {
131  }
132  BlocksSchematic blocks;
133  };
134  void rebuild_internal(bool from_undo, const std::string &comment) override;
135  void history_push(const std::string &comment) override;
136  void history_load(unsigned int i) override;
137  std::string get_history_comment_context() const override;
138  void save(const std::string &suffix) override;
139  void delete_autosave() override;
140  void fix_current_block();
141 };
142 } // namespace horizon
Definition: bom_export_settings.hpp:12
Definition: block_instance.hpp:8
Definition: block_symbol.hpp:51
A block is one level of hierarchy in the netlist.
Definition: block.hpp:29
Definition: blocks_schematic.hpp:8
Definition: core_schematic.hpp:14
Definition: core.hpp:202
Where Tools and and documents meet.
Definition: core.hpp:42
Definition: file_version.hpp:9
Definition: idocument_block_symbol.hpp:5
Definition: idocument_schematic.hpp:6
Definition: iinstancce_mapping_provider.hpp:4
Definition: ipool.hpp:14
A Junction is a point in 2D-Space.
Definition: junction.hpp:20
Definition: layer_provider.hpp:7
Definition: pdf_export_settings.hpp:9
Definition: core_properties.hpp:90
Definition: core_properties.hpp:7
Definition: rules.hpp:53
Definition: schematic_rules.hpp:10
A Schematic is the visual representation of a Block.
Definition: schematic.hpp:29
Definition: sheet.hpp:42
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16