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 <vector>
9 #include <map>
10 #include <fstream>
11 
12 namespace horizon {
13 using json = nlohmann::json;
14 
26 class Schematic {
27 private:
28  Schematic(const UUID &uu, const json &, Block &block, class Pool &pool);
29  unsigned int update_nets();
30 
31 
32 public:
33  static Schematic new_from_file(const std::string &filename, Block &block, Pool &pool);
34  Schematic(const UUID &uu, Block &block);
35 
41  void expand(bool careful = false);
42 
43  Schematic(const Schematic &sch);
44  void operator=(const Schematic &sch);
53  void update_refs();
54 
59  void disconnect_symbol(Sheet *sheet, SchematicSymbol *sym);
60 
65  void autoconnect_symbol(Sheet *sheet, SchematicSymbol *sym);
66 
70  void smash_symbol(Sheet *sheet, SchematicSymbol *sym);
71 
75  void unsmash_symbol(Sheet *sheet, SchematicSymbol *sym);
76 
77 
78  UUID uuid;
79  Block *block;
80  std::string name;
81  std::map<UUID, Sheet> sheets;
82  SchematicRules rules;
83  std::map<std::string, std::string> title_block_values;
84 
85 
86  class Annotation {
87  public:
88  Annotation(const json &j);
89  Annotation();
90  enum class Order { RIGHT_DOWN, DOWN_RIGHT };
91  Order order = Order::RIGHT_DOWN;
92 
93  enum class Mode { SEQUENTIAL, SHEET_100, SHEET_1000 };
94  Mode mode = Mode::SHEET_100;
95 
96  bool fill_gaps = true;
97  bool keep = true;
98  bool ignore_unknown = false;
99  json serialize() const;
100  };
101 
102  Annotation annotation;
103  void annotate();
104 
105  json serialize() const;
106 };
107 } // namespace horizon
A Schematic is the visual representation of a Block.
Definition: schematic.hpp:26
void disconnect_symbol(Sheet *sheet, SchematicSymbol *sym)
Removes all connections from sym and connects the dangling net lines to junctions.
Definition: schematic.cpp:177
a class to store JSON values
Definition: json.hpp:161
void autoconnect_symbol(Sheet *sheet, SchematicSymbol *sym)
Connects unconnected pins of sym to Nets specified by junctions coincident with pins.
Definition: schematic.cpp:87
Definition: schematic_rules.hpp:10
void expand(bool careful=false)
This is where the magic happens.
Definition: schematic.cpp:258
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
void smash_symbol(Sheet *sheet, SchematicSymbol *sym)
Turns sym&#39;s texts to regular text objects.
Definition: schematic.cpp:213
void unsmash_symbol(Sheet *sheet, SchematicSymbol *sym)
Undoes what smash_symbol did.
Definition: schematic.cpp:243
Definition: sheet.hpp:37
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
Stores objects (Unit, Entity, Symbol, Part, etc.) from the pool.
Definition: pool.hpp:19
Definition: block.cpp:9
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
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:708
Definition: schematic_symbol.hpp:19
Definition: schematic.hpp:86