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 <glibmm/regex.h>
10 #include <vector>
11 #include <map>
12 #include <fstream>
13 #include "util/file_version.hpp"
14 
15 namespace horizon {
16 using json = nlohmann::json;
17 
29 class Schematic {
30 private:
31  Schematic(const UUID &uu, const json &, Block &block, class IPool &pool);
32  unsigned int update_nets();
33 
34 public:
35  static Schematic new_from_file(const std::string &filename, Block &block, IPool &pool);
36  Schematic(const UUID &uu, Block &block);
37 
43  void expand(bool careful = false);
44 
45  Schematic(const Schematic &sch);
46  void operator=(const Schematic &sch) = delete;
55  void update_refs();
56 
62 
68 
72  void smash_symbol(Sheet *sheet, SchematicSymbol *sym);
73 
77  void unsmash_symbol(Sheet *sheet, SchematicSymbol *sym);
78 
79  bool delete_net_line(Sheet *sheet, LineNet *line);
80 
81  bool place_bipole_on_line(Sheet *sheet, SchematicSymbol *sym);
82 
83  void swap_gates(const UUID &comp, const UUID &g1, const UUID &g2);
84 
85  std::map<UUIDPath<2>, std::string> get_unplaced_gates() const;
86 
87  static Glib::RefPtr<Glib::Regex> get_sheetref_regex();
88 
89  UUID uuid;
90  Block *block;
91  std::string name;
92  std::map<UUID, Sheet> sheets;
93  SchematicRules rules;
94  bool group_tag_visible = false;
95 
96 
97  class Annotation {
98  public:
99  Annotation(const json &j);
100  Annotation();
101  enum class Order { RIGHT_DOWN, DOWN_RIGHT };
102  Order order = Order::RIGHT_DOWN;
103 
104  enum class Mode { SEQUENTIAL, SHEET_100, SHEET_1000 };
105  Mode mode = Mode::SHEET_100;
106 
107  bool fill_gaps = true;
108  bool keep = true;
109  bool ignore_unknown = false;
110  json serialize() const;
111  };
112 
113  Annotation annotation;
114  void annotate();
115 
116  PDFExportSettings pdf_export_settings;
117 
118  FileVersion version;
119 
120  json serialize() const;
121  void save_pictures(const std::string &dir) const;
122  void load_pictures(const std::string &dir);
123 };
124 } // 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.
horizon::Schematic::Annotation
Definition: schematic.hpp:97
horizon::LineNet
LineNet is similar to Line, except it denotes electrical connection.
Definition: line_net.hpp:23
horizon::Schematic::autoconnect_symbol
void autoconnect_symbol(Sheet *sheet, SchematicSymbol *sym)
Connects unconnected pins of sym to Nets specified by junctions coincident with pins.
horizon::Block
A block is one level of hierarchy in the netlist.
Definition: block.hpp:25
horizon::SchematicSymbol
Definition: schematic_symbol.hpp:17
horizon::Sheet
Definition: sheet.hpp:38
horizon::Schematic
A Schematic is the visual representation of a Block.
Definition: schematic.hpp:29
horizon::Schematic::expand
void expand(bool careful=false)
This is where the magic happens.
horizon::SchematicRules
Definition: schematic_rules.hpp:10
nlohmann::basic_json
a class to store JSON values
Definition: json.hpp:166
horizon::Schematic::smash_symbol
void smash_symbol(Sheet *sheet, SchematicSymbol *sym)
Turns sym's texts to regular text objects.
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.
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
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...