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) const 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  std::string get_display_name(ObjectType type, const UUID &uu, const UUID &sheet) override;
56 
57  class Rules *get_rules() override;
58 
59  BOMExportSettings *get_bom_export_settings()
60  {
61  return &bom_export_settings;
62  }
63 
64  PDFExportSettings *get_pdf_export_settings()
65  {
66  return &pdf_export_settings;
67  }
68 
69  void rebuild(bool from_undo = false) override;
70  void commit() override;
71  void revert() override;
72 
73  void add_sheet();
74  void delete_sheet(const UUID &uu);
75 
76  void set_sheet(const UUID &uu);
77  const Sheet *get_canvas_data();
78  std::pair<Coordi, Coordi> get_bbox() override;
79 
80  bool can_search_for_object_type(ObjectType type) const override;
81  std::list<SearchResult> search(const SearchQuery &q) override;
82 
83  const std::string &get_filename() const override;
84 
85 private:
86  Block block;
87 
88  Schematic sch;
89 
90  SchematicRules rules;
91 
92  BOMExportSettings bom_export_settings;
93  PDFExportSettings pdf_export_settings;
94 
95  UUID sheet_uuid;
96  std::string m_schematic_filename;
97  std::string m_block_filename;
98 
99  class HistoryItem : public Core::HistoryItem {
100  public:
101  HistoryItem(const Block &b, const Schematic &s) : block(b), sch(s)
102  {
103  }
104  Block block;
105  Schematic sch;
106  };
107  void history_push() override;
108  void history_load(unsigned int i) override;
109  void save(const std::string &suffix) override;
110  void delete_autosave() override;
111 };
112 } // namespace horizon
horizon::Line
Graphical line.
Definition: line.hpp:19
horizon::Rules
Definition: rules.hpp:44
horizon::LineNet
LineNet is similar to Line, except it denotes electrical connection.
Definition: line_net.hpp:24
horizon::CoreSchematic::rebuild
void rebuild(bool from_undo=false) override
Expands the non-working document.
Definition: core_schematic.cpp:564
horizon::Arc
Graphical arc.
Definition: arc.hpp:20
horizon::Block
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
horizon::SchematicSymbol
Definition: schematic_symbol.hpp:19
horizon::LayerProvider
Definition: layer_provider.hpp:7
horizon::Symbol
Definition: symbol.hpp:74
horizon::CoreSchematic
Definition: core_schematic.hpp:11
horizon::Sheet
Definition: sheet.hpp:37
horizon::Schematic
A Schematic is the visual representation of a Block.
Definition: schematic.hpp:27
horizon::Core
Where Tools and and documents meet.
Definition: core.hpp:240
horizon::Junction
A Junction is a point in 2D-Space.
Definition: junction.hpp:25
horizon::PropertyMeta
Definition: core_properties.hpp:77
horizon::SchematicRules
Definition: schematic_rules.hpp:10
horizon::Text
Used wherever a user-editable text is needed.
Definition: text.hpp:19
horizon::Core::SearchQuery
Definition: core.hpp:351
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:21
horizon::BOMExportSettings
Definition: bom_export_settings.hpp:11
horizon::PDFExportSettings
Definition: pdf_export_settings.hpp:9
horizon::Core::HistoryItem
Definition: core.hpp:498
horizon::PropertyValue
Definition: core_properties.hpp:7