Horizon
core_schematic.hpp
1 #pragma once
2 #include "block/block.hpp"
3 #include "core.hpp"
4 #include "schematic/schematic.hpp"
5 #include "document/idocument_schematic.hpp"
6 #include <memory>
7 
8 namespace horizon {
9 class CoreSchematic : public Core, public virtual IDocumentSchematic {
10 public:
11  CoreSchematic(const std::string &schematic_filename, const std::string &block_filename,
12  const std::string &pictures_dir, IPool &pool);
13  bool has_object_type(ObjectType ty) const override;
14 
15  Junction *get_junction(const UUID &uu) override;
16  Line *get_line(const UUID &uu) override;
17  Arc *get_arc(const UUID &uu) override;
18  SchematicSymbol *get_schematic_symbol(const UUID &uu) override;
19  Schematic *get_schematic() override;
20  Sheet *get_sheet() override;
21  const Sheet *get_sheet() const;
22  Text *get_text(const UUID &uu) override;
23 
24  Junction *insert_junction(const UUID &uu) override;
25  void delete_junction(const UUID &uu) override;
26  Line *insert_line(const UUID &uu) override;
27  void delete_line(const UUID &uu) override;
28  Arc *insert_arc(const UUID &uu) override;
29  void delete_arc(const UUID &uu) override;
30  SchematicSymbol *insert_schematic_symbol(const UUID &uu, const Symbol *sym) override;
31  void delete_schematic_symbol(const UUID &uu) override;
32 
33  LineNet *insert_line_net(const UUID &uu) override;
34  void delete_line_net(const UUID &uu) override;
35 
36  Text *insert_text(const UUID &uu) override;
37  void delete_text(const UUID &uu) override;
38 
39  class Picture *insert_picture(const UUID &uu) override;
40  class Picture *get_picture(const UUID &uu) override;
41  void delete_picture(const UUID &uu) override;
42 
43  std::vector<Line *> get_lines() override;
44  std::vector<Arc *> get_arcs() override;
45  std::vector<LineNet *> get_net_lines() override;
46  std::vector<NetLabel *> get_net_labels() override;
47 
48  class Block *get_block() override;
49  class LayerProvider &get_layer_provider() override;
50 
51  bool set_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
52  const class PropertyValue &value) override;
53  bool get_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
54  class PropertyValue &value) override;
55  bool get_property_meta(ObjectType type, const UUID &uu, ObjectProperty::ID property,
56  class PropertyMeta &meta) override;
57 
58  std::string get_display_name(ObjectType type, const UUID &uu) override;
59  std::string get_display_name(ObjectType type, const UUID &uu, const UUID &sheet) override;
60 
61  class Rules *get_rules() override;
62 
63  BOMExportSettings *get_bom_export_settings()
64  {
65  return &bom_export_settings;
66  }
67 
68  PDFExportSettings *get_pdf_export_settings()
69  {
70  return &pdf_export_settings;
71  }
72 
73  void rebuild(bool from_undo = false) override;
74 
75  void add_sheet();
76  void delete_sheet(const UUID &uu);
77 
78  void set_sheet(const UUID &uu);
79  const Sheet *get_canvas_data();
80  std::pair<Coordi, Coordi> get_bbox() override;
81 
82  const std::string &get_filename() const override;
83 
84  bool get_project_meta_loaded_from_block() const
85  {
86  return project_meta_loaded_from_block;
87  };
88 
89  ObjectType get_object_type() const override
90  {
91  return ObjectType::SCHEMATIC;
92  }
93 
94  const FileVersion &get_version() const override
95  {
96  return sch.version;
97  }
98 
99 private:
100  Block block;
101  const bool project_meta_loaded_from_block;
102  Schematic sch;
103 
104  SchematicRules rules;
105 
106  BOMExportSettings bom_export_settings;
107  PDFExportSettings pdf_export_settings;
108 
109  UUID sheet_uuid;
110  std::string m_schematic_filename;
111  std::string m_block_filename;
112  std::string m_pictures_dir;
113 
114  class HistoryItem : public Core::HistoryItem {
115  public:
116  HistoryItem(const Block &b, const Schematic &s) : block(b), sch(s)
117  {
118  }
119  Block block;
120  Schematic sch;
121  };
122  void history_push() override;
123  void history_load(unsigned int i) override;
124  void save(const std::string &suffix) override;
125  void delete_autosave() override;
126 };
127 } // namespace horizon
horizon::CoreSchematic::rebuild
void rebuild(bool from_undo=false) override
Expands the non-working document.
horizon::Sheet
Definition: sheet.hpp:38
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16