Horizon
schematic.hpp
1 #pragma once
2 #include "util/uuid.hpp"
3 #include "nlohmann/json_fwd.hpp"
4 #include "pool/unit.hpp"
5 #include "block/block.hpp"
6 #include "sheet.hpp"
7 #include "schematic_rules.hpp"
8 #include "common/pdf_export_settings.hpp"
9 #include <vector>
10 #include <map>
11 #include <fstream>
12 
13 namespace horizon {
14 using json = nlohmann::json;
15 
27 class Schematic {
28 private:
29  Schematic(const UUID &uu, const json &, Block &block, class Pool &pool);
30  unsigned int update_nets();
31 
32 
33 public:
34  static Schematic new_from_file(const std::string &filename, Block &block, Pool &pool);
35  Schematic(const UUID &uu, Block &block);
36 
42  void expand(bool careful = false);
43 
44  Schematic(const Schematic &sch);
45  void operator=(const Schematic &sch) = delete;
54  void update_refs();
55 
60  void disconnect_symbol(Sheet *sheet, SchematicSymbol *sym);
61 
66  void autoconnect_symbol(Sheet *sheet, SchematicSymbol *sym);
67 
71  void smash_symbol(Sheet *sheet, SchematicSymbol *sym);
72 
76  void unsmash_symbol(Sheet *sheet, SchematicSymbol *sym);
77 
78  bool delete_net_line(Sheet *sheet, LineNet *line);
79 
80  bool place_bipole_on_line(Sheet *sheet, SchematicSymbol *sym);
81 
82  std::map<UUIDPath<2>, std::string> get_unplaced_gates() const;
83 
84  UUID uuid;
85  Block *block;
86  std::string name;
87  std::map<UUID, Sheet> sheets;
88  SchematicRules rules;
89  bool group_tag_visible = false;
90 
91 
92  class Annotation {
93  public:
94  Annotation(const json &j);
95  Annotation();
96  enum class Order { RIGHT_DOWN, DOWN_RIGHT };
97  Order order = Order::RIGHT_DOWN;
98 
99  enum class Mode { SEQUENTIAL, SHEET_100, SHEET_1000 };
100  Mode mode = Mode::SHEET_100;
101 
102  bool fill_gaps = true;
103  bool keep = true;
104  bool ignore_unknown = false;
105  json serialize() const;
106  };
107 
108  Annotation annotation;
109  void annotate();
110 
111  PDFExportSettings pdf_export_settings;
112 
113  json serialize() const;
114 };
115 } // namespace horizon
horizon::Schematic::disconnect_symbol
void disconnect_symbol(Sheet *sheet, SchematicSymbol *sym)
Removes all connections from sym and connects the dangling net lines to junctions.
Definition: schematic.cpp:194
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Schematic::Annotation
Definition: schematic.hpp:92
horizon::LineNet
LineNet is similar to Line, except it denotes electrical connection.
Definition: line_net.hpp:24
horizon::Schematic::autoconnect_symbol
void autoconnect_symbol(Sheet *sheet, SchematicSymbol *sym)
Connects unconnected pins of sym to Nets specified by junctions coincident with pins.
Definition: schematic.cpp:93
horizon::Block
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
horizon::SchematicSymbol
Definition: schematic_symbol.hpp:19
horizon::Sheet
Definition: sheet.hpp:37
horizon::Schematic
A Schematic is the visual representation of a Block.
Definition: schematic.hpp:27
horizon::Schematic::expand
void expand(bool careful=false)
This is where the magic happens.
Definition: schematic.cpp:456
horizon::SchematicRules
Definition: schematic_rules.hpp:10
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:165
horizon::Schematic::smash_symbol
void smash_symbol(Sheet *sheet, SchematicSymbol *sym)
Turns sym's texts to regular text objects.
Definition: schematic.cpp:230
horizon::UUID
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
horizon::Schematic::unsmash_symbol
void unsmash_symbol(Sheet *sheet, SchematicSymbol *sym)
Undoes what smash_symbol did.
Definition: schematic.cpp:264
horizon::Pool
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:21
horizon::Schematic::update_refs
void update_refs()
objects owned by the Sheets may hold pointers to other objects of the same sheet or the Block associa...
Definition: schematic.cpp:951
horizon::PDFExportSettings
Definition: pdf_export_settings.hpp:9