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 
14 namespace horizon {
15 using json = nlohmann::json;
16 
28 class Schematic {
29 private:
30  Schematic(const UUID &uu, const json &, Block &block, class Pool &pool);
31  unsigned int update_nets();
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  void swap_gates(const UUID &comp, const UUID &g1, const UUID &g2);
83 
84  std::map<UUIDPath<2>, std::string> get_unplaced_gates() const;
85 
86  static Glib::RefPtr<Glib::Regex> get_sheetref_regex();
87 
88  UUID uuid;
89  Block *block;
90  std::string name;
91  std::map<UUID, Sheet> sheets;
92  SchematicRules rules;
93  bool group_tag_visible = false;
94 
95 
96  class Annotation {
97  public:
98  Annotation(const json &j);
99  Annotation();
100  enum class Order { RIGHT_DOWN, DOWN_RIGHT };
101  Order order = Order::RIGHT_DOWN;
102 
103  enum class Mode { SEQUENTIAL, SHEET_100, SHEET_1000 };
104  Mode mode = Mode::SHEET_100;
105 
106  bool fill_gaps = true;
107  bool keep = true;
108  bool ignore_unknown = false;
109  json serialize() const;
110  };
111 
112  Annotation annotation;
113  void annotate();
114 
115  PDFExportSettings pdf_export_settings;
116 
117  json serialize() const;
118  void save_pictures(const std::string &dir) const;
119  void load_pictures(const std::string &dir);
120 };
121 } // 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:195
nlohmann::json
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61
horizon::Schematic::Annotation
Definition: schematic.hpp:96
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:94
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:38
horizon::Schematic
A Schematic is the visual representation of a Block.
Definition: schematic.hpp:28
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:231
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:1004
horizon::PDFExportSettings
Definition: pdf_export_settings.hpp:9