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  unsigned int update_nets();
32 
33 public:
34  Schematic(const UUID &uu, const json &, Block &block, class IPool &pool);
35  static Schematic new_from_file(const std::string &filename, Block &block, IPool &pool);
36  Schematic(const UUID &uu, Block &block);
37  static unsigned int get_app_version();
38 
44  void expand(bool careful = false);
45 
46  Schematic(const Schematic &sch);
47  void operator=(const Schematic &sch) = delete;
56  void update_refs();
57 
62  void disconnect_symbol(Sheet *sheet, SchematicSymbol *sym);
63 
68  void autoconnect_symbol(Sheet *sheet, SchematicSymbol *sym);
69 
73  void smash_symbol(Sheet *sheet, SchematicSymbol *sym);
74 
78  void unsmash_symbol(Sheet *sheet, SchematicSymbol *sym);
79 
80  bool delete_net_line(Sheet *sheet, LineNet *line);
81 
82  bool place_bipole_on_line(Sheet *sheet, SchematicSymbol *sym);
83 
84  void swap_gates(const UUID &comp, const UUID &g1, const UUID &g2);
85 
86  std::map<UUIDPath<2>, std::string> get_unplaced_gates() const;
87 
88  static Glib::RefPtr<Glib::Regex> get_sheetref_regex();
89 
90  UUID uuid;
91  Block *block;
92  std::string name;
93  std::map<UUID, Sheet> sheets;
94  SchematicRules rules;
95  bool group_tag_visible = false;
96 
97 
98  class Annotation {
99  public:
100  Annotation(const json &j);
101  Annotation();
102  enum class Order { RIGHT_DOWN, DOWN_RIGHT };
103  Order order = Order::RIGHT_DOWN;
104 
105  enum class Mode { SEQUENTIAL, SHEET_100, SHEET_1000 };
106  Mode mode = Mode::SHEET_100;
107 
108  bool fill_gaps = true;
109  bool keep = true;
110  bool ignore_unknown = false;
111  json serialize() const;
112  };
113 
114  Annotation annotation;
115  void annotate();
116 
117  PDFExportSettings pdf_export_settings;
118 
119  FileVersion version;
120 
121  json serialize() const;
122  void save_pictures(const std::string &dir) const;
123  void load_pictures(const std::string &dir);
124 
125  ItemSet get_pool_items_used() const;
126 };
127 } // namespace horizon
A block is one level of hierarchy in the netlist.
Definition: block.hpp:26
Definition: file_version.hpp:8
Definition: ipool.hpp:12
LineNet is similar to Line, except it denotes electrical connection.
Definition: line_net.hpp:17
Definition: pdf_export_settings.hpp:9
Definition: schematic_rules.hpp:10
Definition: schematic_symbol.hpp:17
Definition: schematic.hpp:98
A Schematic is the visual representation of a Block.
Definition: schematic.hpp:29
void expand(bool careful=false)
This is where the magic happens.
Definition: schematic.cpp:466
void smash_symbol(Sheet *sheet, SchematicSymbol *sym)
Turns sym's texts to regular text objects.
Definition: schematic.cpp:241
void unsmash_symbol(Sheet *sheet, SchematicSymbol *sym)
Undoes what smash_symbol did.
Definition: schematic.cpp:274
void autoconnect_symbol(Sheet *sheet, SchematicSymbol *sym)
Connects unconnected pins of sym to Nets specified by junctions coincident with pins.
Definition: schematic.cpp:103
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:1035
void disconnect_symbol(Sheet *sheet, SchematicSymbol *sym)
Removes all connections from sym and connects the dangling net lines to junctions.
Definition: schematic.cpp:205
Definition: sheet.hpp:39
This class encapsulates a UUID and allows it to be uses as a value type.
Definition: uuid.hpp:16
a class to store JSON values
Definition: json.hpp:166
basic_json<> json
default JSON class
Definition: json_fwd.hpp:61