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  UUID uuid;
83  Block *block;
84  std::string name;
85  std::map<UUID, Sheet> sheets;
86  SchematicRules rules;
87  std::map<std::string, std::string> title_block_values;
88  bool group_tag_visible = false;
89 
90 
91  class Annotation {
92  public:
93  Annotation(const json &j);
94  Annotation();
95  enum class Order { RIGHT_DOWN, DOWN_RIGHT };
96  Order order = Order::RIGHT_DOWN;
97 
98  enum class Mode { SEQUENTIAL, SHEET_100, SHEET_1000 };
99  Mode mode = Mode::SHEET_100;
100 
101  bool fill_gaps = true;
102  bool keep = true;
103  bool ignore_unknown = false;
104  json serialize() const;
105  };
106 
107  Annotation annotation;
108  void annotate();
109 
110  PDFExportSettings pdf_export_settings;
111 
112  json serialize() const;
113 };
114 } // 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:189
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Schematic::Annotation
Definition: schematic.hpp:91
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:451
horizon::SchematicRules
Definition: schematic_rules.hpp:10
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:161
horizon::Schematic::smash_symbol
void smash_symbol(Sheet *sheet, SchematicSymbol *sym)
Turns sym's texts to regular text objects.
Definition: schematic.cpp:225
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:259
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:917
horizon::PDFExportSettings
Definition: pdf_export_settings.hpp:9