Horizon
core_schematic.hpp
1 #pragma once
2 #include "block/block.hpp"
3 #include "core.hpp"
4 #include "pool/pool.hpp"
5 #include "pool/symbol.hpp"
6 #include "schematic/schematic.hpp"
7 #include <iostream>
8 #include <memory>
9 
10 namespace horizon {
11 class CoreSchematic : public Core {
12 public:
13  CoreSchematic(const std::string &schematic_filename, const std::string &block_filename, Pool &pool);
14  bool has_object_type(ObjectType ty) override;
15 
16  Junction *get_junction(const UUID &uu, bool work = true) override;
17  Line *get_line(const UUID &uu, bool work = true) override;
18  Arc *get_arc(const UUID &uu, bool work = true) override;
19  SchematicSymbol *get_schematic_symbol(const UUID &uu, bool work = true);
20  Schematic *get_schematic(bool work = true);
21  Sheet *get_sheet(bool work = true);
22  Text *get_text(const UUID &uu, bool work = true) override;
23 
24  Junction *insert_junction(const UUID &uu, bool work = true) override;
25  void delete_junction(const UUID &uu, bool work = true) override;
26  Line *insert_line(const UUID &uu, bool work = true) override;
27  void delete_line(const UUID &uu, bool work = true) override;
28  Arc *insert_arc(const UUID &uu, bool work = true) override;
29  void delete_arc(const UUID &uu, bool work = true) override;
30  SchematicSymbol *insert_schematic_symbol(const UUID &uu, const Symbol *sym, bool work = true);
31  void delete_schematic_symbol(const UUID &uu, bool work = true);
32 
33  LineNet *insert_line_net(const UUID &uu, bool work = true);
34  void delete_line_net(const UUID &uu, bool work = true);
35 
36  Text *insert_text(const UUID &uu, bool work = true) override;
37  void delete_text(const UUID &uu, bool work = true) override;
38 
39  std::vector<Line *> get_lines(bool work = true) override;
40  std::vector<Arc *> get_arcs(bool work = true) override;
41  std::vector<LineNet *> get_net_lines(bool work = true);
42  std::vector<NetLabel *> get_net_labels(bool work = true);
43 
44  class Block *get_block(bool work = true) override;
45  class LayerProvider *get_layer_provider() override;
46 
47  bool set_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
48  const class PropertyValue &value) override;
49  bool get_property(ObjectType type, const UUID &uu, ObjectProperty::ID property,
50  class PropertyValue &value) override;
51  bool get_property_meta(ObjectType type, const UUID &uu, ObjectProperty::ID property,
52  class PropertyMeta &meta) override;
53 
54  std::string get_display_name(ObjectType type, const UUID &uu) override;
55 
56  class Rules *get_rules() override;
57 
58  BOMExportSettings *get_bom_export_settings()
59  {
60  return &bom_export_settings;
61  }
62 
63  void rebuild(bool from_undo = false) override;
64  void commit() override;
65  void revert() override;
66  void save() override;
67 
68  void add_sheet();
69  void delete_sheet(const UUID &uu);
70 
71  void set_sheet(const UUID &uu);
72  const Sheet *get_canvas_data();
73  std::pair<Coordi, Coordi> get_bbox() override;
74 
75 private:
76  Block block;
77 
78  Schematic sch;
79 
80  SchematicRules rules;
81 
82  BOMExportSettings bom_export_settings;
83 
84  UUID sheet_uuid;
85  std::string m_schematic_filename;
86  std::string m_block_filename;
87 
88  class HistoryItem : public Core::HistoryItem {
89  public:
90  HistoryItem(const Block &b, const Schematic &s) : block(b), sch(s)
91  {
92  }
93  Block block;
94  Schematic sch;
95  };
96  void history_push() override;
97  void history_load(unsigned int i) override;
98 };
99 } // namespace horizon
A Schematic is the visual representation of a Block.
Definition: schematic.hpp:26
Graphical line.
Definition: line.hpp:19
Definition: core_properties.hpp:7
LineNet is similar to Line, except it denotes electrical connection.
Definition: line_net.hpp:24
void rebuild(bool from_undo=false) override
Expands the non-working document.
Definition: core_schematic.cpp:523
Definition: schematic_rules.hpp:10
Definition: bom_export_settings.hpp:10
Definition: rules.hpp:44
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
Used wherever a user-editable text is needed.
Definition: text.hpp:19
Where Tools and and documents meet.
Definition: core.hpp:232
Definition: sheet.hpp:37
Definition: layer_provider.hpp:7
Definition: core_properties.hpp:77
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Definition: symbol.hpp:74
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:19
Definition: block.cpp:9
Definition: core.hpp:449
A Junction is a point in 2D-Space.
Definition: junction.hpp:25
Definition: core_schematic.hpp:11
Definition: schematic_symbol.hpp:19
Graphical arc.
Definition: arc.hpp:20