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  void rebuild(bool from_undo = false) override;
59  void commit() override;
60  void revert() override;
61  void save() override;
62 
63  void add_sheet();
64  void delete_sheet(const UUID &uu);
65 
66  void set_sheet(const UUID &uu);
67  const Sheet *get_canvas_data();
68  std::pair<Coordi, Coordi> get_bbox() override;
69 
70 private:
71  Block block;
72 
73  Schematic sch;
74 
75  SchematicRules rules;
76 
77  UUID sheet_uuid;
78  std::string m_schematic_filename;
79  std::string m_block_filename;
80 
81  class HistoryItem : public Core::HistoryItem {
82  public:
83  HistoryItem(const Block &b, const Schematic &s) : block(b), sch(s)
84  {
85  }
86  Block block;
87  Schematic sch;
88  };
89  void history_push() override;
90  void history_load(unsigned int i) override;
91 };
92 } // 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:496
Definition: schematic_rules.hpp:10
Definition: rules.hpp:41
A block is one level of hierarchy in the netlist.
Definition: block.hpp:25
Used wherever a user-editable text is needed.
Definition: text.hpp:18
Where Tools and and documents meet.
Definition: core.hpp:249
Definition: sheet.hpp:35
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:70
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:18
Definition: block.cpp:7
Definition: core.hpp:439
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